Skip to content

Commit

Permalink
import/import-url: try not to delete dvcfile before import/import-url…
Browse files Browse the repository at this point in the history
… completes (#8876)

* import/import-url: try not to delete dvcfile before import/import-url completes

* use repo.stage.create instead of internal create_stage utility
  • Loading branch information
skshetry authored Jan 25, 2023
1 parent 3427e11 commit bb9a3a0
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions dvc/repo/imp_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ def imp_url( # noqa: C901
fs_config=None,
version_aware: bool = False,
):
from dvc.dvcfile import load_file
from dvc.stage import Stage, create_stage, restore_fields

out = resolve_output(url, out)
path, wdir, out = resolve_paths(
self, out, always_local=to_remote and not out
Expand Down Expand Up @@ -64,22 +61,19 @@ def imp_url( # noqa: C901
fs_config = {}
fs_config["version_aware"] = True

stage = create_stage(
Stage,
self,
fname or path,
stage = self.stage.create(
single_stage=True,
validate=False,
fname=fname or path,
wdir=wdir,
deps=[url],
outs=[out],
erepo=erepo,
fs_config=fs_config,
)
restore_fields(stage)

out_obj = stage.outs[0]
out_obj.annot.update(desc=desc, type=type, labels=labels, meta=meta)
dvcfile = load_file(self, stage.path)
dvcfile.remove()

try:
self.check_graph(stages={stage})
Expand All @@ -102,7 +96,5 @@ def imp_url( # noqa: C901
stage.outs[0].can_push = False

stage.frozen = frozen

dvcfile.dump(stage)

stage.dump()
return stage

0 comments on commit bb9a3a0

Please sign in to comment.