Skip to content

feat: release_service_utils as python package#790

Draft
midnightercz wants to merge 1 commit into
mainfrom
rs-python-package
Draft

feat: release_service_utils as python package#790
midnightercz wants to merge 1 commit into
mainfrom
rs-python-package

Conversation

@midnightercz

Copy link
Copy Markdown
Contributor

scripts/python/* is now shipped as python
package which can be imported as release_service_utils

@qodo-app-for-konflux-ci

Copy link
Copy Markdown

Review Summary by Qodo

Convert scripts/python to importable release_service_utils package

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Convert scripts/python into importable release_service_utils package
• Update imports across helpers and tasks to use package namespace
• Add setuptools configuration for package distribution
• Reorganize task structure with internal module hierarchy
Diagram
flowchart LR
  A["scripts/python"] -->|"becomes package"| B["release_service_utils"]
  B -->|"contains"| C["helpers"]
  B -->|"contains"| D["tasks"]
  D -->|"contains"| E["internal"]
  F["pyproject.toml"] -->|"configures"| B
  G["Module imports"] -->|"updated to"| H["from release_service_utils.helpers import X"]

Loading

Grey Divider

File Changes

1. scripts/python/__init__.py ✨ Enhancement +1/-0

Add package initialization file

scripts/python/init.py


2. scripts/python/helpers/__init__.py ✨ Enhancement +10/-0

Export all helper modules via all

scripts/python/helpers/init.py


3. scripts/python/helpers/authentication.py ✨ Enhancement +1/-1

Update import to use package namespace

scripts/python/helpers/authentication.py


View more (17)
4. scripts/python/helpers/osidb.py ✨ Enhancement +1/-1

Update import to use package namespace

scripts/python/helpers/osidb.py


5. scripts/python/helpers/tests/test_osidb.py 🧪 Tests +3/-3

Update mock patches for package imports

scripts/python/helpers/tests/test_osidb.py


6. scripts/python/tasks/__init__.py ✨ Enhancement +1/-0

Add tasks package initialization file

scripts/python/tasks/init.py


7. scripts/python/tasks/internal/__init__.py ✨ Enhancement +1/-0

Add internal tasks package initialization

scripts/python/tasks/internal/init.py


8. scripts/python/tasks/internal/check_fbc_opt_in.py ✨ Enhancement +0/-200

Remove standalone script, convert to module

scripts/python/tasks/internal/check_fbc_opt_in.py


9. scripts/python/tasks/internal/tests/test_check_fbc_opt_in.py 🧪 Tests +2/-1

Update imports to use package namespace

scripts/python/tasks/internal/tests/test_check_fbc_opt_in.py


10. pyproject.toml ⚙️ Configuration changes +15/-0

Add setuptools configuration for package

pyproject.toml


11. scripts/python/helpers/tests/__init__.py Additional files +0/-0

...

scripts/python/helpers/tests/init.py


12. scripts/python/helpers/tests/test_authentication.py Additional files +0/-0

...

scripts/python/helpers/tests/test_authentication.py


13. scripts/python/helpers/tests/test_file.py Additional files +0/-0

...

scripts/python/helpers/tests/test_file.py


14. scripts/python/helpers/tests/test_http_client.py Additional files +0/-0

...

scripts/python/helpers/tests/test_http_client.py


15. scripts/python/helpers/tests/test_image_ref.py Additional files +0/-0

...

scripts/python/helpers/tests/test_image_ref.py


16. scripts/python/helpers/tests/test_logger.py Additional files +0/-0

...

scripts/python/helpers/tests/test_logger.py


17. scripts/python/helpers/tests/test_retry.py Additional files +0/-0

...

scripts/python/helpers/tests/test_retry.py


18. scripts/python/helpers/tests/test_tekton.py Additional files +0/-0

...

scripts/python/helpers/tests/test_tekton.py


19. scripts/python/tasks/internal/tests/__init__.py Additional files +0/-0

...

scripts/python/tasks/internal/tests/init.py


20. scripts/python/tasks/internal/tests/test_check_embargoed_cves.py Additional files +0/-0

...

scripts/python/tasks/internal/tests/test_check_embargoed_cves.py


Grey Divider

Qodo Logo

@qodo-app-for-konflux-ci

qodo-app-for-konflux-ci Bot commented May 28, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0)

Grey Divider


Action required

1. Missing check_fbc_opt_in module 🐞 Bug ≡ Correctness
Description
The PR deletes check_fbc_opt_in.py, but the codebase still imports
release_service_utils.tasks.internal.check_fbc_opt_in, which will fail at import time and break
the task/tests/package.
Code

scripts/python/tasks/internal/check_fbc_opt_in.py[L1-10]

Relevance

⭐⭐⭐ High

Module and tests were added in #765; deleting while still imported will break CI/package.

PR-#765

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The test suite imports the packaged module path
release_service_utils.tasks.internal.check_fbc_opt_in, but the PR removes the only corresponding
implementation file (check_fbc_opt_in.py), so the import target is no longer present.

scripts/python/tasks/internal/tests/test_check_fbc_opt_in.py[10-16]
pyproject.toml[30-40]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`scripts/python/tasks/internal/check_fbc_opt_in.py` was deleted, but `release_service_utils.tasks.internal.check_fbc_opt_in` is still imported. This will raise `ModuleNotFoundError` anywhere that import runs.

### Issue Context
The PR configures setuptools to package `release_service_utils.tasks.internal` from `scripts/python`.

### Fix Focus Areas
- scripts/python/tasks/internal/tests/test_check_fbc_opt_in.py[10-16]
- pyproject.toml[30-40]

### What to change
- Either restore `scripts/python/tasks/internal/check_fbc_opt_in.py` (keeping the same public API used by tests: `parse_container_images`, `get_fbc_opt_in`, `run_check`, `main`).
- Or, if the task is intentionally removed, delete/replace all imports and tests that reference it and remove any packaging references if applicable.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Packaged tasks use flat imports 🐞 Bug ≡ Correctness
Description
The project is being packaged as release_service_utils (including
release_service_utils.tasks.internal), but parts of the codebase still rely on flat
PYTHONPATH-style imports (e.g., import authentication/osidb/http_client) while other modules
have switched to release_service_utils.helpers.*, causing imports to fail depending on whether the
code is run from an installed package or a flat-module environment.
Code

pyproject.toml[R30-40]

Relevance

⭐⭐ Medium

No prior reviews on package-vs-PYTHONPATH import consistency; earlier Python-task PRs kept flat
imports (#738,#765).

PR-#738
PR-#765

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The provided context shows pyproject.toml maps release_service_utils to scripts/python and
explicitly includes release_service_utils.tasks.internal for packaging, which means in an
installed wheel/sdist the helpers will live under release_service_utils.helpers.* rather than as
top-level modules. At the same time, task code such as
scripts/python/tasks/internal/check_embargoed_cves.py still uses flat imports, and the
container/pytest setup is described as setting PYTHONPATH to expose scripts/python/helpers (and
task dirs) as flat modules; this conflicts with helpers/authentication.py and helpers/osidb.py
now importing release_service_utils.helpers.*, leading to `ModuleNotFoundError:
release_service_utils` in the flat environment and unresolved flat helper imports in the
installed-package environment.

pyproject.toml[30-40]
scripts/python/tasks/internal/check_embargoed_cves.py[33-41]
Dockerfile[157-160]
pyproject.toml[44-49]
scripts/python/helpers/authentication.py[11-17]
scripts/python/helpers/osidb.py[16-21]
scripts/python/helpers/tests/test_authentication.py[10-13]
scripts/python/helpers/tests/test_osidb.py[7-11]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The repo currently mixes two incompatible import/runtime models: (1) an installed-package layout where code must import via `release_service_utils...` (as configured in `pyproject.toml`, including `release_service_utils.tasks.internal`), and (2) a flat-module layout where `PYTHONPATH` exposes `scripts/python/helpers` so tasks/tests do `import authentication`, `import osidb`, etc. Because tasks like `check_embargoed_cves.py` still use flat imports while `helpers/authentication.py` and `helpers/osidb.py` now require `release_service_utils` to be importable, imports can fail depending on execution context.

## Issue Context
- `pyproject.toml` maps the package name `release_service_utils` to `scripts/python` and packages `release_service_utils.tasks.internal`, so installed execution expects package-qualified imports.
- The container and pytest environment are described as setting `PYTHONPATH` to include `scripts/python/helpers` (and task paths) to support flat imports, but under that setup `release_service_utils` is not importable unless the project is installed or runtime paths are changed.
- Tasks/tests importing `authentication`/`osidb` can break because those helper modules now import `release_service_utils.helpers.*`, while installed runs can break because task modules still import helpers as top-level names.

## Fix Focus Areas
- pyproject.toml[30-40]
- pyproject.toml[44-49]
- scripts/python/tasks/internal/check_embargoed_cves.py[36-41]
- scripts/python/helpers/authentication.py[11-17]
- scripts/python/helpers/osidb.py[16-21]
- Dockerfile[157-160]

## Implementation direction
Pick one model and apply it consistently across tasks/helpers/tests and the runtime configuration (do not mix modes):

1) **Fully move to installed package imports**
- Ensure the Docker image installs the project (e.g., `pip install .` / `uv pip install .`) and remove/stop relying on flat-import `PYTHONPATH` entries for `scripts/python/helpers` and task dirs.
- Update all task modules under `scripts/python/tasks/internal/` to replace flat imports with package-qualified imports, e.g. `from release_service_utils.helpers import authentication, file, http_client, osidb, tekton` (or more specific `from release_service_utils.helpers.<module> import ...`).
- Ensure tests and any other import sites also use `release_service_utils...` so `python -m release_service_utils.tasks.internal.<task>` works after installation.

OR

2) **Keep the flat `PYTHONPATH`/flat-import model**
- Revert helper modules that now import `release_service_utils.helpers.*` back to flat imports so they can be imported as top-level modules when `scripts/python/helpers` is on `PYTHONPATH`.
- Keep tasks importing helpers as top-level modules and ensure the container/pytest `PYTHONPATH` continues to expose the expected directories.

Choose one approach and make the code and environment agree.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR packages the existing scripts/python utilities as the importable release_service_utils Python package and adds tests around helper/task behavior.

Changes:

  • Adds setuptools package configuration and package __init__.py files.
  • Updates selected helper imports toward package-qualified paths.
  • Adds/updates tests for helpers and internal task modules.

Reviewed changes

Copilot reviewed 10 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml Adds build-system and setuptools package mapping.
uv.lock Updates editable project metadata and dependency lock entries.
scripts/python/__init__.py Adds root package initializer.
scripts/python/helpers/__init__.py Defines exported helper module names.
scripts/python/helpers/authentication.py Switches retry import to package-qualified helper path.
scripts/python/helpers/osidb.py Switches http_client import to package-qualified helper path.
scripts/python/helpers/tests/test_authentication.py Adds authentication helper tests.
scripts/python/helpers/tests/test_file.py Adds file helper tests.
scripts/python/helpers/tests/test_http_client.py Adds HTTP client helper tests.
scripts/python/helpers/tests/test_image_ref.py Adds image reference helper tests.
scripts/python/helpers/tests/test_logger.py Adds logger helper tests.
scripts/python/helpers/tests/test_osidb.py Updates mocks for packaged osidb dependency access.
scripts/python/helpers/tests/test_retry.py Adds retry helper tests.
scripts/python/helpers/tests/test_tekton.py Adds Tekton helper tests.
scripts/python/helpers/tests/__init__.py Marks helper tests package.
scripts/python/tasks/__init__.py Adds tasks package initializer.
scripts/python/tasks/internal/__init__.py Adds internal tasks package initializer.
scripts/python/tasks/internal/check_fbc_opt_in.py Removes the FBC opt-in task implementation.
scripts/python/tasks/internal/tests/test_check_fbc_opt_in.py Updates FBC opt-in test import to package path.
scripts/python/tasks/internal/tests/test_check_embargoed_cves.py Adds embargoed CVE task tests.
scripts/python/tasks/internal/tests/__init__.py Marks internal task tests package.
Comments suppressed due to low confidence (1)

scripts/python/tasks/internal/tests/test_check_fbc_opt_in.py:15

  • This import points to release_service_utils.tasks.internal.check_fbc_opt_in, but the PR deletes scripts/python/tasks/internal/check_fbc_opt_in.py and there is no replacement module under the package. As a result, this test module (and any package consumer importing the FBC opt-in task) fails with ModuleNotFoundError; keep/move the implementation into release_service_utils.tasks.internal or update the test and packaging to the actual new module location.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment thread pyproject.toml
Comment thread scripts/python/tasks/internal/check_fbc_opt_in.py
@midnightercz midnightercz marked this pull request as draft May 28, 2026 14:47
@midnightercz midnightercz force-pushed the rs-python-package branch 4 times, most recently from 8826eb6 to f3c9706 Compare May 29, 2026 11:52
@qodo-code-review qodo-code-review Bot deleted a comment from qodo-app-for-konflux-ci Bot May 29, 2026
@midnightercz midnightercz force-pushed the rs-python-package branch 2 times, most recently from 6afb866 to 3cb759d Compare June 1, 2026 12:44
@qodo-code-review qodo-code-review Bot deleted a comment from qodo-app-for-konflux-ci Bot Jun 1, 2026
@codecov-commenter

codecov-commenter commented Jun 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.45%. Comparing base (1686656) to head (553f988).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #790   +/-   ##
=======================================
  Coverage   93.45%   93.45%           
=======================================
  Files          32       33    +1     
  Lines        2414     2415    +1     
=======================================
+ Hits         2256     2257    +1     
  Misses        158      158           
Flag Coverage Δ
unit-tests 93.45% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
scripts/python/helpers/__init__.py 100.00% <100.00%> (ø)
scripts/python/helpers/authentication.py 100.00% <100.00%> (ø)
scripts/python/helpers/osidb.py 100.00% <100.00%> (ø)
...ipts/python/tasks/internal/check_embargoed_cves.py 100.00% <100.00%> (ø)
scripts/python/tasks/internal/check_fbc_opt_in.py 98.97% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@midnightercz

Copy link
Copy Markdown
Contributor Author

/ok-to-test

@midnightercz midnightercz force-pushed the rs-python-package branch 2 times, most recently from 7aba83b to 52d627c Compare June 2, 2026 08:23
@qodo-code-review qodo-code-review Bot deleted a comment from qodo-app-for-konflux-ci Bot Jun 2, 2026
@midnightercz

Copy link
Copy Markdown
Contributor Author

/ok-to-test

scripts/python/* is now shipped as python
package which can be imported as release_service_utils

Assisted-By: claude
Signed-off-by: Jindrich Luza <jluza@redhat.com>
@midnightercz

Copy link
Copy Markdown
Contributor Author

/ok-to-test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants