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

Recipe modifications #47

Merged
merged 9 commits into from
Aug 5, 2024
Merged

Recipe modifications #47

merged 9 commits into from
Aug 5, 2024

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Aug 4, 2024

No description provided.

@wolfv wolfv force-pushed the recipe-modifications branch 2 times, most recently from 4ae9571 to b03b9eb Compare August 4, 2024 10:22
@wolfv wolfv force-pushed the recipe-modifications branch from b03b9eb to 9677830 Compare August 4, 2024 10:25
return f.getvalue()


class CouldNotUpdateVersionError(Exception):
Copy link
Collaborator

Choose a reason for hiding this comment

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

wdyt about moving errors in separate modules?

yield source


def update_hash(source: dict[str, Any], url: str, hash_type: Hash | None) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can try to annotate it as a typeddict total = False where we expect sha256 and md5 key to be present

src/rattler_build_conda_compat/modify_recipe.py Outdated Show resolved Hide resolved
src/rattler_build_conda_compat/modify_recipe.py Outdated Show resolved Hide resolved
super().__init__(self.message)


class Hash:
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe let's move it in separate module? like hash.py for example?

return f"{self.hash_type}: {self.hash_value}"


def has_jinja_version(url: str) -> bool:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this also can be moved in utils.py as it seems something useful potentially to have for other modules

@nichmor
Copy link
Collaborator

nichmor commented Aug 5, 2024

A more high level question:
Wdyt about update_build_number and update_build_version API to receive already loaded yaml instead of it's path?
I think loading it should be on caller responsibility, we just update it

src/rattler_build_conda_compat/modify_recipe.py Outdated Show resolved Hide resolved
Comment on lines +44 to +45
with file.open("r") as f:
data = yaml.load(f)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesnt it make more sense to leave the loading of the yaml to the caller? I can imagine that if we have more modification functions they will all require loading the yaml.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, and no - we do want to minimally change the YAML so I think that should all be handled by us (leave comments in tact, order, formatting, ...).

src/rattler_build_conda_compat/modify_recipe.py Outdated Show resolved Hide resolved
src/rattler_build_conda_compat/modify_recipe.py Outdated Show resolved Hide resolved
Comment on lines +115 to +116
with file.open("r") as f:
data = yaml.load(f)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, maybe it would make sense to have a variant that takes the loaded dictionary as input.

@baszalmstra
Copy link
Collaborator

You should also add proper docstrings to all public functions. Especially explaining their return value and exceptions they can raise.


logger = logging.getLogger(__name__)

yaml = YAML()
Copy link
Collaborator

Choose a reason for hiding this comment

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

wdyt about extracting YAML loader configuration in one place so it can be used by other loaders?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I also want to get rid of any PyYAML and just use ruamel.YAML everywhere.

Copy link
Member Author

Choose a reason for hiding this comment

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

In fact, that's the next PR that I wanted to send, so let's maybe wait until then?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds good to me

@wolfv wolfv merged commit 4d920bd into prefix-dev:main Aug 5, 2024
7 checks passed
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.

3 participants