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

Use reusable-pytest.yml for all repos that use pytest #183

Open
jtherrmann opened this issue Sep 30, 2024 · 2 comments
Open

Use reusable-pytest.yml for all repos that use pytest #183

jtherrmann opened this issue Sep 30, 2024 · 2 comments
Labels
Jira Task Create a Jira Task for this issue

Comments

@jtherrmann
Copy link
Contributor

jtherrmann commented Sep 30, 2024

Jira: https://asfdaac.atlassian.net/browse/TOOL-3144

Note: The above link is accessible only to members of ASF.


Currently, reusable-pytest.yml assumes the presence of a local Python package:

  1. It requires a local_package_name input.
  2. It runs python -m pip install --no-deps . before running pytest.

It would be nice to support non-package repos as well, e.g. https://github.com/ASFHyP3/hyp3.

With regard to (1), I would suggest renaming local_package_name to something like pytest_cov_source and make it optional with a default value of "", which means no source filtering (see the --cov documentation in pytest --help after installing pytest-cov).

With regard to (2), one option would be to remove the python -m pip install --no-deps . line from the action and require that any repos with a local package include the following in environment.yml:

  - pip:
    - -e .

Another option would be to use Pixi with the path parameter, as suggested by @jhkennedy.

Also note that any of our repos that set PYTHONPATH in Makefile would need to instead set it in environment.yml before being able to use reusable-pytest.yml (see https://asfdaac.atlassian.net/browse/TOOL-3029).

@jtherrmann jtherrmann added the Jira Task Create a Jira Task for this issue label Sep 30, 2024
@jhkennedy
Copy link
Contributor

An alternative worth considering: Don't have non-package repos.

Right now, we only do that because lambda just Yolo's everything onto the PYTHONPATH, but that's against modern Python practices/styles, where you generally try to avoid manipulating the PYTHONPATH directly.

We could update our repos to package all our code and use the packaged code in lambda.

@jtherrmann jtherrmann changed the title Generalize reusable-pytest.yml to support non-package repos Use reusable-pytest.yml for all repos that use pytest Sep 30, 2024
@jhkennedy
Copy link
Contributor

jhkennedy commented Oct 17, 2024

PEP 735 was just accepted that could be relevant to "packaging" infrastructure with multiple lambdas:
https://peps.python.org/pep-0735/

This will provide a way to record independent requirements.txt files in a pyproject.toml and could provide a cleaner way to handle cloud "packages", potentially when combined with inline script metadata.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Jira Task Create a Jira Task for this issue
Projects
None yet
Development

No branches or pull requests

2 participants