Skip to content

FIX: Use traits to provide type hints when modifying paths #2949

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
wants to merge 3 commits into from

Conversation

effigies
Copy link
Member

Summary

This may not be the best way to do things, but in all cases where we're calling modify_paths, we have a traited spec that we can use to provide type hints, if we're careful about inspecting a fairly inconsistent API. Hopefully this falls back to the old behavior.

Additionally, I created a function resolve_path which should provide a consistent convention for returning absolute or relative paths, given an absolute or relative path, with respect to a base directory. This allowed some of the logic of modify_paths to be simplified, although that hardly makes up for the total muddle that is the type hints.

Let me know what you think, @oesteban, @satra, @stilley2. If this seems like the way to go, I can finish it up.

TODO:

  • Test cases for modify_paths
  • May need to comment on type hints bits

Fixes #2944.

Acknowledgment

  • (Mandatory) I acknowledge that this contribution will be available under the Apache 2 license.

@@ -455,7 +466,7 @@ def format_node(node, format='python', include_config=False):
return lines


def modify_paths(object, relative=True, basedir=None):
def modify_paths(object, relative=True, basedir=None, type_hints=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@effigies - you may want to take a peek at the recursive inputs hash function in core specs. since the hints tell whether to hash a path (nested or not) or not, i think that function may be relevant in this scenario.

@stilley2
Copy link
Contributor

Using traits is a much better solution than my proposed fix. My knowledge of the traits system isn't so great, so I don't have any comments on the implementation itself.

oesteban added a commit to oesteban/nipype that referenced this pull request Aug 1, 2019
oesteban added a commit to oesteban/nipype that referenced this pull request Aug 2, 2019
@oesteban oesteban closed this in 5f917f2 Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workflow crashing with file not found due to strange nipype.pipeline.engine.utils.modify_path behavior
3 participants