Skip to content

Commit

Permalink
Address problem with single job views (#211)
Browse files Browse the repository at this point in the history
* Address problem with single job views

* Fix signature, add test

* Update changelog
  • Loading branch information
vyasr authored and csadorf committed Jul 19, 2019
1 parent f83f86d commit 03c0405
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ next
- Fix issue causing a failure of the automatic conversion of valid key types (#168, #205).
- Improve the 'dots in keys' error message to make it easier to fix related issues (#170, #205).
- Update the ``__repr__`` and ``__repr_html__`` implementations of the ``Project`, ``Job``, and ``JobsCursor`` classes (#193).
- Fix issue with rendering views from the command line for single job project (#208).
- Fix issue with heterogeneous types in state point values that are lists (#209).

[1.1.0] -- 2019-05-19
Expand Down
4 changes: 3 additions & 1 deletion signac/contrib/import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def _make_schema_based_path_function(jobs, exclude_keys=None, delimiter_nested='
"Generate schema based paths as a function of the given jobs."
from .schema import _build_job_statepoint_index
if len(jobs) <= 1:
return lambda job: ''
# The lambda must (optionally) take a format spec argument to match the
# signature of the path function below.
return lambda job, sep=None: ''

index = [{'_id': job._id, 'statepoint': job.sp()} for job in jobs]
jsi = _build_job_statepoint_index(jobs=jobs, exclude_const=True, index=index)
Expand Down
15 changes: 15 additions & 0 deletions tests/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,21 @@ def test_index(self):
self.assertIn('b', doc)
self.assertEqual(doc['b'], 0)

def test_view_single(self):
"""Check whether command line views work for single job workspaces."""
self.call('python -m signac init my_project'.split())
project = signac.Project()
sps = [{'a': i} for i in range(1)]
for sp in sps:
project.open_job(sp).init()
os.mkdir('view')
self.call('python -m signac view'.split())
for sp in sps:
self.assertTrue(os.path.isdir('view/job'))
self.assertEqual(
os.path.realpath('view/job'),
os.path.realpath(project.open_job(sp).workspace()))

def test_view(self):
self.call('python -m signac init my_project'.split())
project = signac.Project()
Expand Down

0 comments on commit 03c0405

Please sign in to comment.