-
Notifications
You must be signed in to change notification settings - Fork 6
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
Initial support for manifest build #877
Conversation
cli/rack/__init__.py
Outdated
subdir = to_path.parent.joinpath(dirname) | ||
mkdir(subdir) | ||
self.nodegroups(base_path.joinpath(path), subdir) | ||
step['nodegroups'] = str(dirname) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of duplicated if clauses above. One possible alternative:
for attr in [ 'manifest', 'model', ''data', 'nodegroups' ]:
if attr in step:
path = step[attr]
dirname = Path(f'{self.next_fresh():02}_{attr}')
subdir = to_path.parent.joinpath(dirname)
subdir.mkdir(parents=True, exist_ok=False)
topath = subdir.joinpath(Path(path).name)
# nodegroups is different for the following two; if that's intended, use if attr == "nodegroups" just here...
getattr(self, attr)(base_path.joinpath(path), topath))
step[attr] = str(dirname.joinpath(path).name)
break # [optional]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that there's a bit of duplication here. I'm hesitant to try and factor out more of the commonality because I think the future holds more diversity in ingestion steps (if there's new ones to come) than less, and I don't want to make the code more complicated just to try and eliminate some of the duplication.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small python idiom comment, but otherwise looks good to me.
No description provided.