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

Refactor project #24

Merged
merged 10 commits into from
Jul 2, 2024
Merged

Refactor project #24

merged 10 commits into from
Jul 2, 2024

Conversation

ggonzr
Copy link
Contributor

@ggonzr ggonzr commented Jun 6, 2024

Related to: #23

ggonzr added 6 commits June 6, 2024 18:39
1. Delete everything and use `poetry` to rebuild the project structure, manage dependencies and handle development commands
1. Provide a handler to manage session cookies and configure `requests.Session` to use them.
2. Plan and structure some sketches for other handlers and other components for the project.
1. Authentication handlers available: session cookies, access tokens, and ID tokens.

- Automatically renew the credentials if required.
- Store the credentials in the filesystem, and load them if available to avoid reauthentications. For the ID token handler, refresh the token until the max session lifetime is reached (10h) before asking for a manual reauthentication.
- Set file permissions to `0600`
- Provide tests to check the code's correctness.

2. Update the McM REST client to use the new authentication handlers.

- Enable users to perform arbitrary requests to the same web service via the `request.Session` attribute available at `self.session`.
- Update the tests to use the `pytest` syntax.
1. Logger: Set default level to INFO if the client class does not configure this.
2. Include headers for the non authenticated session.
3. Update session User-Agent header for McM.
4. isort imports.
5. Skip cookie tests if `auth-get-sso-cookie` is not available.
1. Reorder all the content under the `rest` package.
2. Change the project's name.
3. Remove the `fixtures` test module from the final bundle, instead configure `pytest` to include it into its `PYTHONPATH` when tests are executed.
4. Update README: Include instructions about how to build the package automatically with `pip`
1. Downgrade from Python 3.11 to Python 3.9

Python 3.9 is the main version for the alias `python3` in AlmaLinux 9
and `lxplus.cern.ch` nodes. Also, this decision is mainly based on the
Python version available in `cms-sw` apptainer images for `el9`, using a
different version will reduce chances to smoothly integrate this with
some batch execution within McM web application.
@ggonzr ggonzr linked an issue Jun 20, 2024 that may be closed by this pull request
8 tasks
ggonzr added 3 commits June 24, 2024 17:24
1. Configure a session using `access_token`
2. Use decorators and class fixtures to check and skip tests based on the execution runtime environment, and avoid repeating `except` conditions across the test suite
3. Refactor parametrized tests in several functions regarding its authentication method.
4. Skip session cookie tests if no valid Kerberos ticket is available.
5. yield files in fixtures instead of using `os.remove` into tests.
1. Raise a `DeprecationWarning` if someone attempts to access mangled methods in the McM class.
2. Re-include examples about how to use the McM REST class to perform requests to McM.
3. Remove some dead code.
4. Change the logger prefix to `pdmv-http-client`.
5. Fix some grammar issues.
6. Format the code using `black` and `isort`.
@ggonzr
Copy link
Contributor Author

ggonzr commented Jun 25, 2024

Only one script is missing, create_chained_campaigns.py, I will reinclude it in another PR when it is finished as it will require more code to properly plug it in this new project. Also, I consider change_priority.py is not required anymore so I deleted it.

@ggonzr ggonzr marked this pull request as ready for review June 25, 2024 15:15
@ggonzr ggonzr self-assigned this Jun 25, 2024
@ggonzr ggonzr requested a review from lmoureaux June 25, 2024 15:16
lmoureaux
lmoureaux previously approved these changes Jul 1, 2024
Copy link
Contributor

@lmoureaux lmoureaux left a comment

Choose a reason for hiding this comment

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

It's just too much code to be reviewable, so let me just approve.

@ggonzr ggonzr removed a link to an issue Jul 2, 2024
8 tasks
@ggonzr ggonzr merged commit 81d0c23 into master Jul 2, 2024
@ggonzr ggonzr deleted the refactor/rest-client branch July 2, 2024 09:57
@ggonzr ggonzr restored the refactor/rest-client branch July 2, 2024 09:57
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