get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 140057,
    "url": "https://patches.dpdk.org/api/patches/140057/?format=api",
    "web_url": "https://patches.dpdk.org/project/dpdk/patch/20240514114459.1949921-3-luca.vizzarro@arm.com/",
    "project": {
        "id": 1,
        "url": "https://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": "<20240514114459.1949921-3-luca.vizzarro@arm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20240514114459.1949921-3-luca.vizzarro@arm.com",
    "date": "2024-05-14T11:44:58",
    "name": "[v3,2/3] dts: constrain DPDK source argument",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "f5edbe4236515fea6a575134d096a592091d64c7",
    "submitter": {
        "id": 3197,
        "url": "https://patches.dpdk.org/api/people/3197/?format=api",
        "name": "Luca Vizzarro",
        "email": "luca.vizzarro@arm.com"
    },
    "delegate": {
        "id": 1,
        "url": "https://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "https://patches.dpdk.org/project/dpdk/patch/20240514114459.1949921-3-luca.vizzarro@arm.com/mbox/",
    "series": [
        {
            "id": 31921,
            "url": "https://patches.dpdk.org/api/series/31921/?format=api",
            "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=31921",
            "date": "2024-05-14T11:44:56",
            "name": "error and usage improvements",
            "version": 3,
            "mbox": "https://patches.dpdk.org/series/31921/mbox/"
        }
    ],
    "comments": "https://patches.dpdk.org/api/patches/140057/comments/",
    "check": "warning",
    "checks": "https://patches.dpdk.org/api/patches/140057/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 4B51B4402B;\n\tTue, 14 May 2024 13:45:36 +0200 (CEST)",
            "from mails.dpdk.org (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id E02C240696;\n\tTue, 14 May 2024 13:45:21 +0200 (CEST)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by mails.dpdk.org (Postfix) with ESMTP id 81DD240648\n for <dev@dpdk.org>; Tue, 14 May 2024 13:45:19 +0200 (CEST)",
            "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 DE6FA139F;\n Tue, 14 May 2024 04:45:43 -0700 (PDT)",
            "from localhost.localdomain (unknown [10.57.4.224])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 147153F641;\n Tue, 14 May 2024 04:45:17 -0700 (PDT)"
        ],
        "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 Jeremy Spewock <jspewock@iol.unh.edu>,\n Paul Szczepanek <paul.szczepanek@arm.com>",
        "Subject": "[PATCH v3 2/3] dts: constrain DPDK source argument",
        "Date": "Tue, 14 May 2024 12:44:58 +0100",
        "Message-Id": "<20240514114459.1949921-3-luca.vizzarro@arm.com>",
        "X-Mailer": "git-send-email 2.34.1",
        "In-Reply-To": "<20240514114459.1949921-1-luca.vizzarro@arm.com>",
        "References": "<20240318171704.798634-1-luca.vizzarro@arm.com>\n <20240514114459.1949921-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.\n\nSigned-off-by: Luca Vizzarro <luca.vizzarro@arm.com>\nReviewed-by: Paul Szczepanek <paul.szczepanek@arm.com>\n---\n doc/guides/tools/dts.rst  | 39 ++++++++++++------------\n dts/framework/settings.py | 62 +++++++++++++++++++++++++++++----------\n dts/framework/utils.py    | 43 ++++++++++++++++-----------\n 3 files changed, 90 insertions(+), 54 deletions(-)",
    "diff": "diff --git a/doc/guides/tools/dts.rst b/doc/guides/tools/dts.rst\nindex 6993443389..f64ab7f732 100644\n--- a/doc/guides/tools/dts.rst\n+++ b/doc/guides/tools/dts.rst\n@@ -215,41 +215,38 @@ 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 FILE_PATH] [--output-dir DIR_PATH] [-t SECONDS] [-v] [-s] [--tarball FILE_PATH]\n+   usage: main.py [-h] [--config-file FILE_PATH] [--output-dir DIR_PATH] [-t SECONDS] [-v] [-s] (--tarball FILE_PATH | --revision ID)\n                   [--compile-timeout SECONDS] [--test-suite TEST_SUITE [TEST_CASES ...]] [--re-run N_TIMES]\n \n-   Run DPDK test suites. All options may be specified with the environment variables provided in brackets. Command\n-   line arguments have higher priority.\n+   Run DPDK test suites. All options may be specified with the environment variables provided in brackets. Command line arguments have higher\n+   priority.\n \n    options:\n      -h, --help            show this help message and exit\n      --config-file FILE_PATH\n-                           [DTS_CFG_FILE] The configuration file that describes the test cases, SUTs and targets.\n-                           (default: conf.yaml)\n+                           [DTS_CFG_FILE] The configuration file that describes the test cases, SUTs and targets. (default:\n+                           /home/lucviz01/dpdk/dts/conf.yaml)\n      --output-dir DIR_PATH, --output DIR_PATH\n                            [DTS_OUTPUT_DIR] Output directory where DTS logs and results are saved. (default: output)\n      -t SECONDS, --timeout SECONDS\n-                           [DTS_TIMEOUT] The default timeout for all DTS operations except for compiling DPDK.\n-                           (default: 15)\n-     -v, --verbose         [DTS_VERBOSE] Specify to enable verbose output, logging all messages to the console.\n-                           (default: False)\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: False)\n-     --tarball FILE_PATH, --snapshot FILE_PATH, --git-ref FILE_PATH\n-                           [DTS_DPDK_TARBALL] Path to DPDK source code tarball or a git commit ID,tag ID or tree ID to\n-                           test. To test local changes, first commit them, then use the commit ID with this option.\n-                           (default: dpdk.tar.xz)\n+     --tarball FILE_PATH, --snapshot FILE_PATH\n+                           [DTS_DPDK_TARBALL] Path to DPDK source code tarball to test. (default: None)\n+     --revision ID, --rev ID, --git-ref ID\n+                           [DTS_DPDK_REVISION_ID] Git revision ID to test. Could be commit, tag, tree ID etc. To test local changes, first\n+                           commit them, then use their commit ID. (default: None)\n      --compile-timeout SECONDS\n                            [DTS_COMPILE_TIMEOUT] The timeout for compiling DPDK. (default: 1200)\n      --test-suite TEST_SUITE [TEST_CASES ...]\n-                           [DTS_TEST_SUITES] A list containing a test suite with test cases. The first parameter is\n-                           the test suite name, and the rest are test case names, which are optional. May be specified\n-                           multiple times. To specify multiple test suites in the environment variable, join the lists\n-                           with a comma. Examples: --test-suite SUITE1 CASE1 CASE2 --test-suite SUITE2 CASE1 ... |\n-                           DTS_TEST_SUITES='SUITE1 CASE1 CASE2, SUITE2 CASE1, ...' | --test-suite SUITE1 --test-suite SUITE2\n-                           CASE1 ... | DTS_TEST_SUITES='SUITE1, SUITE2 CASE1, ...' (default: [])\n+                           [DTS_TEST_SUITES] A list containing a test suite with test cases. The first parameter is the test suite name, and\n+                           the rest are test case names, which are optional. May be specified multiple times. To specify multiple test suites\n+                           in the environment variable, join the lists with a comma. Examples: --test-suite suite case case --test-suite\n+                           suite case ... | DTS_TEST_SUITES='suite case case, suite case, ...' | --test-suite suite --test-suite suite case\n+                           ... | DTS_TEST_SUITES='suite, suite case, ...' (default: [])\n      --re-run N_TIMES, --re_run N_TIMES\n-                           [DTS_RERUN] Re-run each test case the specified number of times if a test failure occurs.\n-                           (default: 0)\n+                           [DTS_RERUN] Re-run each test case the specified number of times if a test failure occurs. (default: 0)\n \n \n The brackets contain the names of environment variables that set the same thing.\ndiff --git a/dts/framework/settings.py b/dts/framework/settings.py\nindex d7af5adf2d..0bb7f57ed7 100644\n--- a/dts/framework/settings.py\n+++ b/dts/framework/settings.py\n@@ -44,10 +44,16 @@\n \n     Set to any value to skip building DPDK.\n \n-.. option:: --tarball, --snapshot, --git-ref\n+.. option:: --tarball, --snapshot\n .. envvar:: DTS_DPDK_TARBALL\n \n-    The path to a DPDK tarball, git commit ID, tag ID or tree ID to test.\n+    Path to DPDK source code tarball to test.\n+\n+.. option:: --revision, --rev, --git-ref\n+.. envvar:: DTS_DPDK_REVISION_ID\n+\n+    Git revision ID to test. Could be commit, tag, tree ID etc.\n+    To test local changes, first commit them, then use their commit ID.\n \n .. option:: --test-suite\n .. envvar:: DTS_TEST_SUITES\n@@ -84,7 +90,24 @@\n from typing import Callable, ParamSpec\n \n from .config import TestSuiteConfig\n-from .utils import DPDKGitTarball\n+from .exception import ConfigurationError\n+from .utils import DPDKGitTarball, get_commit_id\n+\n+\n+def _parse_tarball_path(file_path: str) -> Path:\n+    \"\"\"Validate whether `file_path` is valid and return a Path object.\"\"\"\n+    path = Path(file_path)\n+    if not path.exists() or not path.is_file():\n+        raise argparse.ArgumentTypeError(\"The file path provided is not a valid file\")\n+    return path\n+\n+\n+def _parse_revision_id(rev_id: str) -> str:\n+    \"\"\"Validate revision ID and retrieve corresponding commit ID.\"\"\"\n+    try:\n+        return get_commit_id(rev_id)\n+    except ConfigurationError:\n+        raise argparse.ArgumentTypeError(\"The Git revision ID supplied is invalid or ambiguous\")\n \n \n @dataclass(slots=True)\n@@ -105,7 +128,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@@ -305,20 +328,30 @@ def _get_parser() -> ArgumentParser:\n         help=\"Specify to skip all setup steps on SUT and TG nodes.\",\n     )\n \n-    add_argument_to_parser_with_env(\n+    dpdk_source = parser.add_mutually_exclusive_group(required=True)\n+    add_argument_to_dpdk_source_with_env = augment_add_argument_with_env(dpdk_source.add_argument)\n+\n+    add_argument_to_dpdk_source_with_env(\n         \"--tarball\",\n         \"--snapshot\",\n-        \"--git-ref\",\n-        default=SETTINGS.dpdk_tarball_path,\n-        type=Path,\n-        help=\"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+        type=_parse_tarball_path,\n+        help=\"Path to DPDK source code tarball to test.\",\n         metavar=\"FILE_PATH\",\n         dest=\"dpdk_tarball_path\",\n         env_var_name=\"DPDK_TARBALL\",\n     )\n \n+    add_argument_to_dpdk_source_with_env(\n+        \"--revision\",\n+        \"--rev\",\n+        \"--git-ref\",\n+        type=_parse_revision_id,\n+        help=\"Git revision ID to test. Could be commit, tag, tree ID etc. \"\n+        \"To test local changes, first commit them, then use their commit ID.\",\n+        metavar=\"ID\",\n+        dest=\"dpdk_revision_id\",\n+    ),\n+\n     add_argument_to_parser_with_env(\n         \"--compile-timeout\",\n         default=SETTINGS.compile_timeout,\n@@ -393,11 +426,8 @@ def get_settings() -> Settings:\n \n     args = parser.parse_args()\n \n-    args.dpdk_tarball_path = Path(\n-        Path(DPDKGitTarball(args.dpdk_tarball_path, args.output_dir))\n-        if not os.path.exists(args.dpdk_tarball_path)\n-        else Path(args.dpdk_tarball_path)\n-    )\n+    if args.dpdk_revision_id:\n+        args.dpdk_tarball_path = DPDKGitTarball(args.dpdk_revision_id, args.output_dir)\n \n     args.test_suites = _process_test_suites(parser, args.test_suites)\n \ndiff --git a/dts/framework/utils.py b/dts/framework/utils.py\nindex 74a11f1aaf..862bafb46c 100644\n--- a/dts/framework/utils.py\n+++ b/dts/framework/utils.py\n@@ -2,6 +2,7 @@\n # Copyright(c) 2010-2014 Intel Corporation\n # Copyright(c) 2022-2023 PANTHEON.tech s.r.o.\n # Copyright(c) 2022-2023 University of New Hampshire\n+# Copyright(c) 2024 Arm Limited\n \n \"\"\"Various utility classes and functions.\n \n@@ -70,6 +71,31 @@ 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 not 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,22 +205,6 @@ 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     def _create_tarball_dir(self) -> None:\n         os.makedirs(self._tarball_dir, exist_ok=True)\n \n",
    "prefixes": [
        "v3",
        "2/3"
    ]
}