Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command line failure when experiment name ends with a dot (Error: Command not found) #709

Closed
antrec opened this issue Jan 15, 2020 · 7 comments
Labels

Comments

@antrec
Copy link

antrec commented Jan 15, 2020

When the experiment name ends with one or several dots ("."), sacred fails to parse the commands (it removes as many letters from the command name as there are dots in the end of the experiment name).

For instance, the following code runs fine:

from sacred import Experiment

ex = Experiment('name_of_exp')

@ex.automain
def my_main():
    print('Hello world!')

But if I change the experiment name:

from sacred import Experiment

ex = Experiment('name_of_exp.')

@ex.automain
def my_main():
    print('Hello world!')

It returns:

Usage:
  test_sacred.py [(with UPDATE...)] [options]
  test_sacred.py help [COMMAND]
  test_sacred.py (-h | --help)
  test_sacred.py COMMAND [(with UPDATE...)] [options]
Error: Command "my_main" not found. Available commands are: int_config, y_main, ve_config, int_dependencies, int_named_configs

(note the 'y_main' appearing instead of 'my_main').
And if I add two dots:

from sacred import Experiment

ex = Experiment('name_of_exp..')

@ex.automain
def my_main():
    print('Hello world!')

It returns:

Usage:
  test_sacred.py [(with UPDATE...)] [options]
  test_sacred.py help [COMMAND]
  test_sacred.py (-h | --help)
  test_sacred.py COMMAND [(with UPDATE...)] [options]
Error: Command "my_main" not found. Available commands are: int_config, _main, ve_config, int_dependencies, int_named_configs

(note the '_main' appearing instead of 'my_main').

And so on.

I got this bug when updating sacred from 0.7.4 to 0.8.1.

@thequilo
Copy link
Collaborator

I'm not sure if this is a bug or not, but it is caused by post_process_name and/or join_paths. First, join_paths joins the experiment name with the command names and makes sure that there is exactly one dot (i.e., a valid path). Then, post_process_name tries to remove the experiment name by just looking at the length of the experiment's name, which is not the same as the prefix anymore, and removes more than necessary. I don't know how to fix this. It looks like experiment names are (now) not supposed to end with dots. If join_paths would not remove the dots the resulting command name_of_exp...my_main wouldn't be a valid path.

@antrec
Copy link
Author

antrec commented Jan 15, 2020

Thanks for the quick reply @thequilo !

Indeed it is perhaps not a bug and the workaround is obvious: do not end the experiment name with a dot. Still, if this behavior is intended then it should be mentioned in the documentation, and if possible it should trigger a specific error message when it happens.

@thequilo
Copy link
Collaborator

That's what I thought as well. Maybe someone who has a little more knowledge about the design choices can have a look at this @Qwlouse or @JarnoRFB?

@antrec can you think of a use case where you want to / have to end the experiment name with a dot? I think it would be easiest if we just don't allow dots in the experiment name or any command names.

@antrec
Copy link
Author

antrec commented Jan 15, 2020

I agree; actually I do not have such use cases, I just happened to have sentences ending with dot as experiment names in my code...

@JarnoRFB
Copy link
Collaborator

Seems to be just an unintended implementation detail. Contributions for a more explicit error message welcome.

@Qwlouse
Copy link
Collaborator

Qwlouse commented Feb 19, 2020

Definitely unintended. The intended usecase for dots is to nest ingredients. I.e. an ingredient called dataset.preprocessing would be nested as _config["dataset"]["preprocessing"] and be locally accessible from within the dataset ingredient. Trailing dots as above would yield empty nesting layers and should probably just be forbidden.

@stale
Copy link

stale bot commented May 19, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants