Skip to content

name_source and _gen_filename #573

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

Closed
satra opened this issue Jun 1, 2013 · 2 comments
Closed

name_source and _gen_filename #573

satra opened this issue Jun 1, 2013 · 2 comments
Labels

Comments

@satra
Copy link
Member

satra commented Jun 1, 2013

i think we need to rethink the name_source and _gen_filename api.

originally _gen_filename was meant to help auto generate filenames when typically a parameter that corresponded to an output was required. so if the output was Undefined _gen_filename would be called allowing interfaces to determine how the output should be called.

pattern:

undefined value + genfile -> gen_filename -> value

name_source extended this to allow more clever naming of the output name, instead of the defaults that the interface supplied.

patterns:

undefined value + genfile -> gen_filename -> value
'%s' in value & genfile & name_source -> gen_filename from name source -> value

the same function _gen_filename was overloaded to handle both these patterns and i think that every place where _gen_filename was used was not checked.

there are two solutions:

  1. keep the single function, but go through every single one of them to ensure that they are behaving appropriately. make sure to write a test for these.

  2. refine the function.

    a. you cannot specify name_source without genfile
    b. all overloaded _gen_filename functions have to call the base class function whenever
    they don't deal with that name

  3. create two separate functions: _filename_from_source and _gen_filename

see the PR for details on option 3.

@bpinsard
Copy link
Contributor

bpinsard commented Jun 2, 2013

there could be also the option to have only name_source and in case the value is required the use_default_value should be set to True and a default value/template provided. This way in the case it is not defined the default template is used and this avoid writing _gen_filename in each interface with a lot of if elif to deal with each option. I think this should be managed as much as possible in the traits specification and handled in generic function of the BaseInterface class.

@satra
Copy link
Member Author

satra commented Jun 2, 2013

i think that's what we will head towards given the refactoring, but we have a lot of interfaces to go through and make sure that we are not breaking anything. especially given that we don't have actual running tests for these interfaces.

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

3 participants