get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/136041/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 136041,
    "url": "http://patches.dpdk.org/api/patches/136041/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20240122182611.1904974-2-luca.vizzarro@arm.com/",
    "project": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20240122182611.1904974-2-luca.vizzarro@arm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240122182611.1904974-2-luca.vizzarro@arm.com",
    "date": "2024-01-22T18:26:08",
    "name": "[1/4] dts: constrain DPDK source flag",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "d36c43572b00b1d26a4081edbfa1e76d5cad5f63",
    "submitter": {
        "id": 3197,
        "url": "http://patches.dpdk.org/api/people/3197/?format=api",
        "name": "Luca Vizzarro",
        "email": "luca.vizzarro@arm.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20240122182611.1904974-2-luca.vizzarro@arm.com/mbox/",
    "series": [
        {
            "id": 30879,
            "url": "http://patches.dpdk.org/api/series/30879/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=30879",
            "date": "2024-01-22T18:26:07",
            "name": "dts: error and usage improvements",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/30879/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/136041/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/136041/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id E07664399C;\n\tMon, 22 Jan 2024 19:26:40 +0100 (CET)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 440E040DDA;\n\tMon, 22 Jan 2024 19:26:36 +0100 (CET)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by mails.dpdk.org (Postfix) with ESMTP id BC83640298\n for <dev@dpdk.org>; Mon, 22 Jan 2024 19:26:34 +0100 (CET)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5BE57FEC;\n Mon, 22 Jan 2024 10:27:20 -0800 (PST)",
            "from localhost.localdomain (unknown [10.57.90.210])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 91B1E3F762;\n Mon, 22 Jan 2024 10:26:33 -0800 (PST)"
        ],
        "From": "Luca Vizzarro <luca.vizzarro@arm.com>",
        "To": "dev@dpdk.org",
        "Cc": "Luca Vizzarro <luca.vizzarro@arm.com>,\n =?utf-8?q?Juraj_Linke=C5=A1?= <juraj.linkes@pantheon.tech>,\n Paul Szczepanek <paul.szczepanek@arm.com>",
        "Subject": "[PATCH 1/4] dts: constrain DPDK source flag",
        "Date": "Mon, 22 Jan 2024 18:26:08 +0000",
        "Message-Id": "<20240122182611.1904974-2-luca.vizzarro@arm.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20240122182611.1904974-1-luca.vizzarro@arm.com>",
        "References": "<20240122182611.1904974-1-luca.vizzarro@arm.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org"
    },
    "content": "DTS needs an input to gather the DPDK source code from. This is then\nbuilt on the remote target. This commit makes sure that this input is\nmore constrained, separating the Git revision ID – used to create a\ntarball using Git – and providing tarballed source code directly, while\nretaining mutual exclusion.\n\nThis makes the code more readable and easier to handle for input\nvalidation, of which this commit introduces a basic one based on the\npre-existing code.\n\nMoreover it ensures that these flags are explicitly required to be set\nby the user, dropping a default value. It also aids the user understand\nhow to use the DTS in the scenario it is ran without any arguments set.\n\nReviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>\nSigned-off-by: Luca Vizzarro <luca.vizzarro@arm.com>\n---\n doc/guides/tools/dts.rst  |  8 +++--\n dts/framework/settings.py | 64 ++++++++++++++++++++++++++++-----------\n dts/framework/utils.py    | 43 ++++++++++++++++----------\n 3 files changed, 79 insertions(+), 36 deletions(-)",
    "diff": "diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst\nindex 846696e14e..6e2da317e8 100644\n--- a/doc/guides/tools/dts.rst\n+++ b/doc/guides/tools/dts.rst\n@@ -215,12 +215,16 @@ DTS is run with ``main.py`` located in the ``dts`` directory after entering Poet\n .. code-block:: console\n \n    (dts-py3.10) $ ./main.py --help\n-   usage: main.py [-h] [--config-file CONFIG_FILE] [--output-dir OUTPUT_DIR] [-t TIMEOUT] [-v] [-s] [--tarball TARBALL] [--compile-timeout COMPILE_TIMEOUT] [--test-cases TEST_CASES] [--re-run RE_RUN]\n+   usage: main.py [-h] (--tarball FILEPATH | --revision ID) [--config-file CONFIG_FILE] [--output-dir OUTPUT_DIR] [-t TIMEOUT] [-v] [-s] [--compile-timeout COMPILE_TIMEOUT] [--test-cases TEST_CASES] [--re-run RE_RUN]\n \n    Run DPDK test suites. All options may be specified with the environment variables provided in brackets. Command line arguments have higher priority.\n \n    options:\n    -h, --help            show this help message and exit\n+   --tarball FILEPATH, --snapshot FILEPATH\n+                         Path to DPDK source code tarball to test. (default: None)\n+   --revision ID, --rev ID, --git-ref ID\n+                         Git revision ID to test. Could be commit, tag, tree ID and vice versa. To test local changes, first commit them, then use their commit ID (default: None)\n    --config-file CONFIG_FILE\n                          [DTS_CFG_FILE] configuration file that describes the test cases, SUTs and targets. (default: ./conf.yaml)\n    --output-dir OUTPUT_DIR, --output OUTPUT_DIR\n@@ -229,8 +233,6 @@ DTS is run with ``main.py`` located in the ``dts`` directory after entering Poet\n                          [DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK. (default: 15)\n    -v, --verbose         [DTS_VERBOSE] Specify to enable verbose output, logging all messages to the console. (default: False)\n    -s, --skip-setup      [DTS_SKIP_SETUP] Specify to skip all setup steps on SUT and TG nodes. (default: None)\n-   --tarball TARBALL, --snapshot TARBALL, --git-ref TARBALL\n-                         [DTS_DPDK_TARBALL] Path to DPDK source code tarball or a git commit ID, tag ID or tree ID to test. To test local changes, first commit them, then use the commit ID with this option. (default: dpdk.tar.xz)\n    --compile-timeout COMPILE_TIMEOUT\n                          [DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK. (default: 1200)\n    --test-cases TEST_CASES\ndiff --git a/dts/framework/settings.py b/dts/framework/settings.py\nindex 609c8d0e62..2d0365e763 100644\n--- a/dts/framework/settings.py\n+++ b/dts/framework/settings.py\n@@ -76,7 +76,8 @@\n from pathlib import Path\n from typing import Any, TypeVar\n \n-from .utils import DPDKGitTarball\n+from .exception import ConfigurationError\n+from .utils import DPDKGitTarball, get_commit_id\n \n _T = TypeVar(\"_T\")\n \n@@ -149,6 +150,26 @@ def __call__(\n     return _EnvironmentArgument\n \n \n+def _parse_tarball(filepath: str) -> Path:\n+    \"\"\"Validate if the filepath is valid and return a Path object.\"\"\"\n+    path = Path(filepath)\n+    if not path.exists() or not path.is_file():\n+        raise argparse.ArgumentTypeError(\n+            \"the file path provided is not a valid file\")\n+    return path\n+\n+\n+def _parse_revision_id(rev_id: str) -> str:\n+    \"\"\"Retrieve effective commit ID from a revision ID. While validating it.\"\"\"\n+\n+    try:\n+        return get_commit_id(rev_id)\n+    except ConfigurationError:\n+        raise argparse.ArgumentTypeError(\n+            \"the Git revision ID supplied is invalid or ambiguous\"\n+        )\n+\n+\n @dataclass(slots=True)\n class Settings:\n     \"\"\"Default framework-wide user settings.\n@@ -167,7 +188,7 @@ class Settings:\n     #:\n     skip_setup: bool = False\n     #:\n-    dpdk_tarball_path: Path | str = \"dpdk.tar.xz\"\n+    dpdk_tarball_path: Path | str = \"\"\n     #:\n     compile_timeout: float = 1200\n     #:\n@@ -186,6 +207,28 @@ def _get_parser() -> argparse.ArgumentParser:\n         formatter_class=argparse.ArgumentDefaultsHelpFormatter,\n     )\n \n+    dpdk_source = parser.add_mutually_exclusive_group(required=True)\n+\n+    dpdk_source.add_argument(\n+        \"--tarball\",\n+        \"--snapshot\",\n+        action='store',\n+        type=_parse_tarball,\n+        help=\"Path to DPDK source code tarball to test.\",\n+        metavar=\"FILEPATH\",\n+    )\n+\n+    dpdk_source.add_argument(\n+        \"--revision\",\n+        \"--rev\",\n+        \"--git-ref\",\n+        type=_parse_revision_id,\n+        metavar=\"ID\",\n+        help=\"Git revision ID to test. Could be commit, tag, tree ID and \"\n+        \"vice versa. To test local changes, first commit them, then use their \"\n+        \"commit ID\",\n+    )\n+\n     parser.add_argument(\n         \"--config-file\",\n         action=_env_arg(\"DTS_CFG_FILE\"),\n@@ -229,18 +272,6 @@ def _get_parser() -> argparse.ArgumentParser:\n         help=\"[DTS_SKIP_SETUP] Specify to skip all setup steps on SUT and TG nodes.\",\n     )\n \n-    parser.add_argument(\n-        \"--tarball\",\n-        \"--snapshot\",\n-        \"--git-ref\",\n-        action=_env_arg(\"DTS_DPDK_TARBALL\"),\n-        default=SETTINGS.dpdk_tarball_path,\n-        type=Path,\n-        help=\"[DTS_DPDK_TARBALL] Path to DPDK source code tarball or a git commit ID, \"\n-        \"tag ID or tree ID to test. To test local changes, first commit them, \"\n-        \"then use the commit ID with this option.\",\n-    )\n-\n     parser.add_argument(\n         \"--compile-timeout\",\n         action=_env_arg(\"DTS_COMPILE_TIMEOUT\"),\n@@ -283,9 +314,8 @@ def get_settings() -> Settings:\n         verbose=parsed_args.verbose,\n         skip_setup=parsed_args.skip_setup,\n         dpdk_tarball_path=Path(\n-            Path(DPDKGitTarball(parsed_args.tarball, parsed_args.output_dir))\n-            if not os.path.exists(parsed_args.tarball)\n-            else Path(parsed_args.tarball)\n+            parsed_args.tarball or\n+            DPDKGitTarball(parsed_args.revision, parsed_args.output_dir)\n         ),\n         compile_timeout=parsed_args.compile_timeout,\n         test_cases=(parsed_args.test_cases.split(\",\") if parsed_args.test_cases else []),\ndiff --git a/dts/framework/utils.py b/dts/framework/utils.py\nindex cc5e458cc8..dbbec8b00a 100644\n--- a/dts/framework/utils.py\n+++ b/dts/framework/utils.py\n@@ -70,6 +70,32 @@ def get_packet_summaries(packets: list[Packet]) -> str:\n     return f\"Packet contents: \\n{packet_summaries}\"\n \n \n+def get_commit_id(rev_id: str) -> str:\n+    \"\"\"Given a Git revision ID, return the corresponding commit ID.\n+\n+    Args:\n+        rev_id: The Git revision ID.\n+\n+    Raises:\n+        ConfigurationError: The ``git rev-parse`` command failed. Suggesting\n+            an invalid or ambiguous revision ID was supplied.\n+    \"\"\"\n+    result = subprocess.run(\n+        [\"git\", \"rev-parse\", \"--verify\", rev_id],\n+        text=True,\n+        capture_output=True,\n+    )\n+    if result.returncode != 0:\n+        raise ConfigurationError(\n+            f\"{rev_id} is neither a path to an existing DPDK \"\n+            \"archive nor a valid git reference.\\n\"\n+            f\"Command: {result.args}\\n\"\n+            f\"Stdout: {result.stdout}\\n\"\n+            f\"Stderr: {result.stderr}\"\n+        )\n+    return result.stdout.strip()\n+\n+\n class StrEnum(Enum):\n     \"\"\"Enum with members stored as strings.\"\"\"\n \n@@ -170,7 +196,6 @@ def __init__(\n \n         self._tarball_dir = Path(output_dir, \"tarball\")\n \n-        self._get_commit_id()\n         self._create_tarball_dir()\n \n         self._tarball_name = (\n@@ -180,21 +205,7 @@ def __init__(\n         if not self._tarball_path:\n             self._create_tarball()\n \n-    def _get_commit_id(self) -> None:\n-        result = subprocess.run(\n-            [\"git\", \"rev-parse\", \"--verify\", self._git_ref],\n-            text=True,\n-            capture_output=True,\n-        )\n-        if result.returncode != 0:\n-            raise ConfigurationError(\n-                f\"{self._git_ref} is neither a path to an existing DPDK \"\n-                \"archive nor a valid git reference.\\n\"\n-                f\"Command: {result.args}\\n\"\n-                f\"Stdout: {result.stdout}\\n\"\n-                f\"Stderr: {result.stderr}\"\n-            )\n-        self._git_ref = result.stdout.strip()\n+\n \n     def _create_tarball_dir(self) -> None:\n         os.makedirs(self._tarball_dir, exist_ok=True)\n",
    "prefixes": [
        "1/4"
    ]
}