Skip to content

Commit

Permalink
ENH: run: Abort if dataset is dirty
Browse files Browse the repository at this point in the history
This prevents problematic cases where the user has uncommitted changes
to files and doesn't realize that the run will take the files from
HEAD.  It also prevents unnecessary work in scenarios like the one
described in gh-447 where the dirty check on the remote side will fail
due to subdataset modifications.

Closes #447.
  • Loading branch information
kyleam committed Aug 23, 2019
1 parent 0ed4551 commit 84981a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions reproman/support/jobs/orchestrators.py
Expand Up @@ -484,6 +484,10 @@ def __init__(self, resource, submission_type, job_spec=None,
if self._resurrection:
self.head = self.job_spec.get("head")
else:
if self.ds.repo.dirty:
raise OrchestratorError("Local dataset {} is dirty. "
"Save or discard uncommitted changes"
.format(self.ds.path))
self._configure_repo()
self.head = self.ds.repo.get_hexsha()
_datalad_check_container(self.ds, self.job_spec)
Expand Down
7 changes: 7 additions & 0 deletions reproman/support/jobs/tests/test_orchestrators.py
Expand Up @@ -405,6 +405,13 @@ def get_orc():
ssh, submission_type="local", job_spec=job_spec)

with chpwd(dataset.path):
# We abort if the local dataset is dirty.
create_tree(dataset.path, {"local-dirt": ""})
with pytest.raises(OrchestratorError) as exc:
get_orc()
assert "dirty" in str(exc.value)
os.unlink("local-dirt")

orc0 = get_orc()
# Run one job so that we create the remote repository.
orc0.prepare_remote()
Expand Down

0 comments on commit 84981a7

Please sign in to comment.