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

Python recipe render improvements #57

Merged
merged 14 commits into from
Jan 7, 2025

Conversation

wolfv
Copy link
Member

@wolfv wolfv commented Sep 19, 2024

This renders the data more properly in order to extract all the sources. The plan is:

  • render the recipe with all variants & original version, extract the sha hashes + URLs
  • re-render the recipe with new $version value and try to get new URLs, and obtain new hashes. If that works, we will find + replace the old hashes in the recipe.

Ideally, this will be implemented in rattler build as a command such as rattler-build bump-version ./recipe -m ./variant-config/*.yaml - but for now I am prototyping this here to get it into the bot.

@wolfv wolfv force-pushed the py-render-improvement branch from 270838d to c9ac681 Compare January 6, 2025 12:14
@wolfv wolfv changed the title WIP: python render improvement Python recipe render improvements Jan 6, 2025
from itertools import product


def variant_combinations(data: dict[str, str | list[str]]) -> list[dict[str, str]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could definitely use a function docstring and explain what the inputs and outputs are.



# Custom constructor for loading floats as strings
def float_as_string_constructor(loader, node) -> str: # noqa: ANN001
return loader.construct_scalar(node)


def convert_to_plain_types(data: Any) -> Any: # noqa: ANN401
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a docstring? What is a plain type?

override_version: str | None = None,
) -> set[Source]:
"""
This function should render _all_ URL sources with the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Incomplete docstring

from itertools import product


def variant_combinations(data: dict[str, str | list[str]]) -> list[dict[str, str]]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does it make sense to add a few test cases specifically for this?

@wolfv wolfv merged commit f7850a8 into prefix-dev:main Jan 7, 2025
6 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.

2 participants