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 ReproNimgh-447 where the dirty check on the remote side will fail
due to subdataset modifications.

Closes ReproNim#447.
  • Loading branch information
kyleam committed Aug 20, 2019
1 parent c247acf commit 9f9e346
Show file tree
Hide file tree
Showing 2 changed files with 12 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
8 changes: 8 additions & 0 deletions reproman/support/jobs/tests/test_orchestrators.py
Expand Up @@ -408,6 +408,14 @@ def test_orc_datalad_pair(job_spec, dataset, shell):
@pytest.mark.integration
def test_orc_datalad_abort_if_dirty(job_spec, dataset, shell):
with chpwd(dataset.path):
# We abort if the local dataset is dirty.
create_tree(dataset.path, {"local-dirt": ""})
with pytest.raises(OrchestratorError) as exc:
orcs.DataladPairOrchestrator(
shell, submission_type="local", job_spec=job_spec)
assert "dirty" in str(exc.value)
os.unlink("local-dirt")

orc0 = orcs.DataladPairOrchestrator(
shell, submission_type="local", job_spec=job_spec)
# Run one job so that we create the remote repository.
Expand Down

0 comments on commit 9f9e346

Please sign in to comment.