prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Implement `--no-exec` option for `import-url` command
  `dvc import-url` creates new `.dvc` file, just as `dvc run`. Sometimes files which would be imported are already present locally and it's quite inconvenient that they should be downloaded again in order to create a pipeline step.
  
  Because of that it would be great to add `--no-exec` option: we create pipeline step, then use `dvc commit` to update its md5 with already downloaded file.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `dvc/repo/imp_url.py`
  Content:
  ```
  1 import os
  2 
  3 from dvc.repo.scm_context import scm_context
  4 from dvc.utils import relpath, resolve_output, resolve_paths
  5 from dvc.utils.fs import path_isin
  6 
  7 from ..exceptions import OutputDuplicationError
  8 from . import locked
  9 
  10 
  11 @locked
  12 @scm_context
  13 def imp_url(self, url, out=None, fname=None, erepo=None, frozen=True):
  14     from dvc.dvcfile import Dvcfile
  15     from dvc.stage import Stage, create_stage
  16 
  17     out = resolve_output(url, out)
  18     path, wdir, out = resolve_paths(self, out)
  19 
  20     # NOTE: when user is importing something from within their own repository
  21     if (
  22         erepo is None
  23         and os.path.exists(url)
  24         and path_isin(os.path.abspath(url), self.root_dir)
  25     ):
  26         url = relpath(url, wdir)
  27 
  28     stage = create_stage(
  29         Stage,
  30         self,
  31         fname or path,
  32         wdir=wdir,
  33         deps=[url],
  34         outs=[out],
  35         erepo=erepo,
  36     )
  37 
  38     if stage is None:
  39         return None
  40 
  41     dvcfile = Dvcfile(self, stage.path)
  42     dvcfile.remove()
  43 
  44     try:
  45         self.check_modified_graph([stage])
  46     except OutputDuplicationError as exc:
  47         raise OutputDuplicationError(exc.output, set(exc.stages) - {stage})
  48 
  49     stage.run()
  50 
  51     stage.frozen = frozen
  52 
  53     dvcfile.dump(stage)
  54 
  55     return stage
  56
  ```
  
  Path: `dvc/command/imp_url.py`
  Content:
  ```
  1 import argparse
  2 import logging
  3 
  4 from dvc.command import completion
  5 from dvc.command.base import CmdBase, append_doc_link
  6 from dvc.exceptions import DvcException
  7 
  8 logger = logging.getLogger(__name__)
  9 
  10 
  11 class CmdImportUrl(CmdBase):
  12     def run(self):
  13         try:
  14             self.repo.imp_url(
  15                 self.args.url, out=self.args.out, fname=self.args.file
  16             )
  17         except DvcException:
  18             logger.exception(
  19                 "failed to import {}. You could also try downloading "
  20                 "it manually, and adding it with `dvc add`.".format(
  21                     self.args.url
  22                 )
  23             )
  24             return 1
  25         return 0
  26 
  27 
  28 def add_parser(subparsers, parent_parser):
  29     IMPORT_HELP = (
  30         "Download or copy file from URL and take it under DVC control."
  31     )
  32 
  33     import_parser = subparsers.add_parser(
  34         "import-url",
  35         parents=[parent_parser],
  36         description=append_doc_link(IMPORT_HELP, "import-url"),
  37         help=IMPORT_HELP,
  38         formatter_class=argparse.RawTextHelpFormatter,
  39     )
  40     import_parser.add_argument(
  41         "url",
  42         help="Supported urls:\n"
  43         "/path/to/file\n"
  44         "/path/to/directory\n"
  45         "C:\\\\path\\to\\file\n"
  46         "C:\\\\path\\to\\directory\n"
  47         "https://example.com/path/to/file\n"
  48         "s3://bucket/path/to/file\n"
  49         "s3://bucket/path/to/directory\n"
  50         "gs://bucket/path/to/file\n"
  51         "gs://bucket/path/to/directory\n"
  52         "hdfs://example.com/path/to/file\n"
  53         "ssh://example.com:/path/to/file\n"
  54         "ssh://example.com:/path/to/directory\n"
  55         "remote://myremote/path/to/file (see `dvc remote`)",
  56     )
  57     import_parser.add_argument(
  58         "out",
  59         nargs="?",
  60         help="Destination path to put files to.",
  61         choices=completion.Optional.DIR,
  62     )
  63     import_parser.add_argument(
  64         "--file",
  65         help="Specify name of the DVC-file this command will generate.",
  66         metavar="<filename>",
  67         choices=completion.Optional.DIR,
  68     )
  69     import_parser.set_defaults(func=CmdImportUrl)
  70
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py
  --- a/dvc/command/imp_url.py
  +++ b/dvc/command/imp_url.py
  @@ -12,7 +12,10 @@
       def run(self):
           try:
               self.repo.imp_url(
  -                self.args.url, out=self.args.out, fname=self.args.file
  +                self.args.url,
  +                out=self.args.out,
  +                fname=self.args.file,
  +                no_exec=self.args.no_exec,
               )
           except DvcException:
               logger.exception(
  @@ -66,4 +69,10 @@
           metavar="<filename>",
           choices=completion.Optional.DIR,
       )
  +    import_parser.add_argument(
  +        "--no-exec",
  +        action="store_true",
  +        default=False,
  +        help="Only create stage file without actually download it.",
  +    )
       import_parser.set_defaults(func=CmdImportUrl)
  diff --git a/dvc/repo/imp_url.py b/dvc/repo/imp_url.py
  --- a/dvc/repo/imp_url.py
  +++ b/dvc/repo/imp_url.py
  @@ -10,7 +10,9 @@
   
   @locked
   @scm_context
  -def imp_url(self, url, out=None, fname=None, erepo=None, frozen=True):
  +def imp_url(
  +    self, url, out=None, fname=None, erepo=None, frozen=True, no_exec=False
  +):
       from dvc.dvcfile import Dvcfile
       from dvc.stage import Stage, create_stage
   
  @@ -46,7 +48,10 @@
       except OutputDuplicationError as exc:
           raise OutputDuplicationError(exc.output, set(exc.stages) - {stage})
   
  -    stage.run()
  +    if no_exec:
  +        stage.ignore_outs()
  +    else:
  +        stage.run()
   
       stage.frozen = frozen
  
verification_info: {"golden_diff": "diff --git a/dvc/command/imp_url.py b/dvc/command/imp_url.py\n--- a/dvc/command/imp_url.py\n+++ b/dvc/command/imp_url.py\n@@ -12,7 +12,10 @@\n     def run(self):\n         try:\n             self.repo.imp_url(\n-                self.args.url, out=self.args.out, fname=self.args.file\n+                self.args.url,\n+                out=self.args.out,\n+                fname=self.args.file,\n+                no_exec=self.args.no_exec,\n             )\n         except DvcException:\n             logger.exception(\n@@ -66,4 +69,10 @@\n         metavar=\"<filename>\",\n         choices=completion.Optional.DIR,\n     )\n+    import_parser.add_argument(\n+        \"--no-exec\",\n+        action=\"store_true\",\n+        default=False,\n+        help=\"Only create stage file without actually download it.\",\n+    )\n     import_parser.set_defaults(func=CmdImportUrl)\ndiff --git a/dvc/repo/imp_url.py b/dvc/repo/imp_url.py\n--- a/dvc/repo/imp_url.py\n+++ b/dvc/repo/imp_url.py\n@@ -10,7 +10,9 @@\n \n @locked\n @scm_context\n-def imp_url(self, url, out=None, fname=None, erepo=None, frozen=True):\n+def imp_url(\n+    self, url, out=None, fname=None, erepo=None, frozen=True, no_exec=False\n+):\n     from dvc.dvcfile import Dvcfile\n     from dvc.stage import Stage, create_stage\n \n@@ -46,7 +48,10 @@\n     except OutputDuplicationError as exc:\n         raise OutputDuplicationError(exc.output, set(exc.stages) - {stage})\n \n-    stage.run()\n+    if no_exec:\n+        stage.ignore_outs()\n+    else:\n+        stage.run()\n \n     stage.frozen = frozen\n", "issue": "Implement `--no-exec` option for `import-url` command\n`dvc import-url` creates new `.dvc` file, just as `dvc run`. Sometimes files which would be imported are already present locally and it's quite inconvenient that they should be downloaded again in order to create a pipeline step.\r\n\r\nBecause of that it would be great to add `--no-exec` option: we create pipeline step, then use `dvc commit` to update its md5 with already downloaded file.\n", "before_files": [{"content": "import os\n\nfrom dvc.repo.scm_context import scm_context\nfrom dvc.utils import relpath, resolve_output, resolve_paths\nfrom dvc.utils.fs import path_isin\n\nfrom ..exceptions import OutputDuplicationError\nfrom . import locked\n\n\n@locked\n@scm_context\ndef imp_url(self, url, out=None, fname=None, erepo=None, frozen=True):\n    from dvc.dvcfile import Dvcfile\n    from dvc.stage import Stage, create_stage\n\n    out = resolve_output(url, out)\n    path, wdir, out = resolve_paths(self, out)\n\n    # NOTE: when user is importing something from within their own repository\n    if (\n        erepo is None\n        and os.path.exists(url)\n        and path_isin(os.path.abspath(url), self.root_dir)\n    ):\n        url = relpath(url, wdir)\n\n    stage = create_stage(\n        Stage,\n        self,\n        fname or path,\n        wdir=wdir,\n        deps=[url],\n        outs=[out],\n        erepo=erepo,\n    )\n\n    if stage is None:\n        return None\n\n    dvcfile = Dvcfile(self, stage.path)\n    dvcfile.remove()\n\n    try:\n        self.check_modified_graph([stage])\n    except OutputDuplicationError as exc:\n        raise OutputDuplicationError(exc.output, set(exc.stages) - {stage})\n\n    stage.run()\n\n    stage.frozen = frozen\n\n    dvcfile.dump(stage)\n\n    return stage\n", "path": "dvc/repo/imp_url.py"}, {"content": "import argparse\nimport logging\n\nfrom dvc.command import completion\nfrom dvc.command.base import CmdBase, append_doc_link\nfrom dvc.exceptions import DvcException\n\nlogger = logging.getLogger(__name__)\n\n\nclass CmdImportUrl(CmdBase):\n    def run(self):\n        try:\n            self.repo.imp_url(\n                self.args.url, out=self.args.out, fname=self.args.file\n            )\n        except DvcException:\n            logger.exception(\n                \"failed to import {}. You could also try downloading \"\n                \"it manually, and adding it with `dvc add`.\".format(\n                    self.args.url\n                )\n            )\n            return 1\n        return 0\n\n\ndef add_parser(subparsers, parent_parser):\n    IMPORT_HELP = (\n        \"Download or copy file from URL and take it under DVC control.\"\n    )\n\n    import_parser = subparsers.add_parser(\n        \"import-url\",\n        parents=[parent_parser],\n        description=append_doc_link(IMPORT_HELP, \"import-url\"),\n        help=IMPORT_HELP,\n        formatter_class=argparse.RawTextHelpFormatter,\n    )\n    import_parser.add_argument(\n        \"url\",\n        help=\"Supported urls:\\n\"\n        \"/path/to/file\\n\"\n        \"/path/to/directory\\n\"\n        \"C:\\\\\\\\path\\\\to\\\\file\\n\"\n        \"C:\\\\\\\\path\\\\to\\\\directory\\n\"\n        \"https://example.com/path/to/file\\n\"\n        \"s3://bucket/path/to/file\\n\"\n        \"s3://bucket/path/to/directory\\n\"\n        \"gs://bucket/path/to/file\\n\"\n        \"gs://bucket/path/to/directory\\n\"\n        \"hdfs://example.com/path/to/file\\n\"\n        \"ssh://example.com:/path/to/file\\n\"\n        \"ssh://example.com:/path/to/directory\\n\"\n        \"remote://myremote/path/to/file (see `dvc remote`)\",\n    )\n    import_parser.add_argument(\n        \"out\",\n        nargs=\"?\",\n        help=\"Destination path to put files to.\",\n        choices=completion.Optional.DIR,\n    )\n    import_parser.add_argument(\n        \"--file\",\n        help=\"Specify name of the DVC-file this command will generate.\",\n        metavar=\"<filename>\",\n        choices=completion.Optional.DIR,\n    )\n    import_parser.set_defaults(func=CmdImportUrl)\n", "path": "dvc/command/imp_url.py"}], "after_files": [{"content": "import os\n\nfrom dvc.repo.scm_context import scm_context\nfrom dvc.utils import relpath, resolve_output, resolve_paths\nfrom dvc.utils.fs import path_isin\n\nfrom ..exceptions import OutputDuplicationError\nfrom . import locked\n\n\n@locked\n@scm_context\ndef imp_url(\n    self, url, out=None, fname=None, erepo=None, frozen=True, no_exec=False\n):\n    from dvc.dvcfile import Dvcfile\n    from dvc.stage import Stage, create_stage\n\n    out = resolve_output(url, out)\n    path, wdir, out = resolve_paths(self, out)\n\n    # NOTE: when user is importing something from within their own repository\n    if (\n        erepo is None\n        and os.path.exists(url)\n        and path_isin(os.path.abspath(url), self.root_dir)\n    ):\n        url = relpath(url, wdir)\n\n    stage = create_stage(\n        Stage,\n        self,\n        fname or path,\n        wdir=wdir,\n        deps=[url],\n        outs=[out],\n        erepo=erepo,\n    )\n\n    if stage is None:\n        return None\n\n    dvcfile = Dvcfile(self, stage.path)\n    dvcfile.remove()\n\n    try:\n        self.check_modified_graph([stage])\n    except OutputDuplicationError as exc:\n        raise OutputDuplicationError(exc.output, set(exc.stages) - {stage})\n\n    if no_exec:\n        stage.ignore_outs()\n    else:\n        stage.run()\n\n    stage.frozen = frozen\n\n    dvcfile.dump(stage)\n\n    return stage\n", "path": "dvc/repo/imp_url.py"}, {"content": "import argparse\nimport logging\n\nfrom dvc.command import completion\nfrom dvc.command.base import CmdBase, append_doc_link\nfrom dvc.exceptions import DvcException\n\nlogger = logging.getLogger(__name__)\n\n\nclass CmdImportUrl(CmdBase):\n    def run(self):\n        try:\n            self.repo.imp_url(\n                self.args.url,\n                out=self.args.out,\n                fname=self.args.file,\n                no_exec=self.args.no_exec,\n            )\n        except DvcException:\n            logger.exception(\n                \"failed to import {}. You could also try downloading \"\n                \"it manually, and adding it with `dvc add`.\".format(\n                    self.args.url\n                )\n            )\n            return 1\n        return 0\n\n\ndef add_parser(subparsers, parent_parser):\n    IMPORT_HELP = (\n        \"Download or copy file from URL and take it under DVC control.\"\n    )\n\n    import_parser = subparsers.add_parser(\n        \"import-url\",\n        parents=[parent_parser],\n        description=append_doc_link(IMPORT_HELP, \"import-url\"),\n        help=IMPORT_HELP,\n        formatter_class=argparse.RawTextHelpFormatter,\n    )\n    import_parser.add_argument(\n        \"url\",\n        help=\"Supported urls:\\n\"\n        \"/path/to/file\\n\"\n        \"/path/to/directory\\n\"\n        \"C:\\\\\\\\path\\\\to\\\\file\\n\"\n        \"C:\\\\\\\\path\\\\to\\\\directory\\n\"\n        \"https://example.com/path/to/file\\n\"\n        \"s3://bucket/path/to/file\\n\"\n        \"s3://bucket/path/to/directory\\n\"\n        \"gs://bucket/path/to/file\\n\"\n        \"gs://bucket/path/to/directory\\n\"\n        \"hdfs://example.com/path/to/file\\n\"\n        \"ssh://example.com:/path/to/file\\n\"\n        \"ssh://example.com:/path/to/directory\\n\"\n        \"remote://myremote/path/to/file (see `dvc remote`)\",\n    )\n    import_parser.add_argument(\n        \"out\",\n        nargs=\"?\",\n        help=\"Destination path to put files to.\",\n        choices=completion.Optional.DIR,\n    )\n    import_parser.add_argument(\n        \"--file\",\n        help=\"Specify name of the DVC-file this command will generate.\",\n        metavar=\"<filename>\",\n        choices=completion.Optional.DIR,\n    )\n    import_parser.add_argument(\n        \"--no-exec\",\n        action=\"store_true\",\n        default=False,\n        help=\"Only create stage file without actually download it.\",\n    )\n    import_parser.set_defaults(func=CmdImportUrl)\n", "path": "dvc/command/imp_url.py"}]}