Skip to content

Commit

Permalink
Merge pull request #342 from donglinjy/develop
Browse files Browse the repository at this point in the history
Inconsistent output in orion status and orion list
  • Loading branch information
bouthilx authored Feb 28, 2020
2 parents 8941ddc + 410f51a commit 6badd44
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
*.pkl
*.lock

# OS generated files
.DS_Store

# StarUML documentation
*.mdj

Expand Down
4 changes: 4 additions & 0 deletions src/orion/core/cli/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def main(args):
root_experiments = [exp for exp in experiments
if exp['refers'].get('root_id', exp['_id']) == exp['_id']]

if not root_experiments:
print("No experiment found")
return

for root_experiment in root_experiments:
root = experiment_builder.build_view(name=root_experiment['name'],
version=root_experiment.get('version')).node
Expand Down
12 changes: 9 additions & 3 deletions src/orion/core/cli/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def main(args):
raise RuntimeError("Cannot fetch specific version of experiments with --collapse "
"or --expand-versions.")

print_evc(filter(lambda e: e.refers.get('parent_id') is None, experiments), **args)
print_evc(experiments, **args)


# pylint: disable=unused-argument
Expand Down Expand Up @@ -104,13 +104,19 @@ def get_experiments(args):
Commandline arguments.
"""
projection = {'name': 1, 'version': 1}
projection = {'name': 1, 'version': 1, 'refers': 1}

query = {'name': args['name']} if args.get('name') else {}
experiments = get_storage().fetch_experiments(query, projection)

if args['name']:
root_experiments = experiments
else:
root_experiments = [exp for exp in experiments
if exp['refers'].get('root_id', exp['_id']) == exp['_id']]

return [experiment_builder.build_view(name=exp['name'], version=exp.get('version', 1))
for exp in experiments]
for exp in root_experiments]


def _has_named_children(exp):
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/commands/test_list_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_no_exp(monkeypatch, clean_db, capsys):

captured = capsys.readouterr().out

assert captured == ""
assert captured == "No experiment found\n"


def test_single_exp(clean_db, one_experiment, capsys):
Expand Down Expand Up @@ -84,7 +84,7 @@ def test_no_exp_name(clean_db, three_experiments, monkeypatch, capsys):

captured = capsys.readouterr().out

assert captured == ""
assert captured == "No experiment found\n"


def test_exp_name(clean_db, three_experiments, monkeypatch, capsys):
Expand Down
29 changes: 29 additions & 0 deletions tests/functional/commands/test_status_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,35 @@ def test_experiment_wout_success_wout_ac(clean_db, single_without_success, capsy
assert captured == expected


def test_experiment_number_same_list_status(clean_db,
single_without_success, capsys):
"""Test status and list command output the consistent number of experiments"""
orion.core.cli.main(['status'])

captured = capsys.readouterr().out

expected = """\
test_single_exp-v1
==================
status quantity
----------- ----------
broken 1
interrupted 1
new 1
reserved 1
suspended 1
"""
assert captured == expected

orion.core.cli.main(['list'])

captured = capsys.readouterr().out

assert captured == " test_single_exp-v1\n"


def test_experiment_w_trials_wout_ac(clean_db, single_with_trials, capsys):
"""Test status with only one experiment and all trials."""
orion.core.cli.main(['status'])
Expand Down

0 comments on commit 6badd44

Please sign in to comment.