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

Initial support for manifest build #877

Merged
merged 6 commits into from
Feb 1, 2023
Merged

Initial support for manifest build #877

merged 6 commits into from
Feb 1, 2023

Conversation

glguy
Copy link
Contributor

@glguy glguy commented Jan 18, 2023

No description provided.

cli/rack/__init__.py Outdated Show resolved Hide resolved
cli/rack/__init__.py Outdated Show resolved Hide resolved
subdir = to_path.parent.joinpath(dirname)
mkdir(subdir)
self.nodegroups(base_path.joinpath(path), subdir)
step['nodegroups'] = str(dirname)
Copy link
Contributor

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]

Copy link
Contributor Author

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.

@glguy glguy marked this pull request as ready for review February 1, 2023 18:57
Copy link
Contributor

@kquick kquick left a 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.

cli/rack/__init__.py Outdated Show resolved Hide resolved
@glguy glguy merged commit 082d610 into master Feb 1, 2023
@glguy glguy deleted the manifest-build branch February 1, 2023 21:05
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.

2 participants