Skip to content

ci: check format with black - #37

Merged
uniqueg merged 10 commits into
devfrom
enable-black-formatting
Oct 19, 2023
Merged

uniqueg merged 10 commits into
devfrom
enable-black-formatting

Conversation

@alohamora

@alohamora alohamora commented Oct 2, 2023 •

Copy link
Copy Markdown
Contributor

Description

This pull request implements all the changes required to standardize formatting for the codebase as mentioned in #36

Fixes #36

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have not reduced the existing code coverage
  • I have added docstrings following the Python style guidelines of this project to all new modules, classes, methods and functions are documented with docstrings following; I have updated any previously existing docstrings, if applicable
  • I have updated any sections of the app's documentation that are affected by the proposed changes, if applicable

@codecov

codecov Bot commented Oct 2, 2023 •

Copy link
Copy Markdown

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (b3d0e5b) 100.00% compared to head (6b78dbb) 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##               dev       #37   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          190       190           
=========================================
  Hits           190       190           
Files Coverage Δ
cloud_registry/exceptions.py 100.00% <ø> (ø)
cloud_registry/ga4gh/registry/server.py 100.00% <100.00%> (ø)
cloud_registry/ga4gh/registry/service.py 100.00% <100.00%> (ø)
cloud_registry/ga4gh/registry/service_info.py 100.00% <100.00%> (ø)
cloud_registry/service_models/custom_config.py 100.00% <ø> (ø)
cloud_registry/version.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@uniqueg uniqueg left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Awesome- thanks a lot! Please go ahead and merge

@uniqueg uniqueg changed the title Enable black formatting ci: enable formatting check with black Oct 2, 2023

@uniqueg uniqueg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wait, Build the Docs failed, likely because of the Pyyaml/Cython issue. Could you incorporate the required version limits in the requirements so that they will be applied for the RtD build as well? 🙏

@alohamora

Copy link
Copy Markdown
Contributor Author

@uniqueg we cannot force the build requirement of cython<3.0.0 in requirements.txt because pip isolates the build environment for each package that is installed. So even if we have installed the correct version of cython, it will try to use the latest version for building pyyaml, because they have not provided any version constraints in their build configuration.

ref - https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/

For building packages using this interface, pip uses an isolated environment. That is, pip will install build-time Python dependencies in a temporary directory which will be added to sys.path for the build commands. This ensures that build requirements are handled independently of the user’s runtime environment.
For example, a project that needs an older version of setuptools to build can still be installed, even if the user has an newer version installed (and without silently replacing that version).

pyyaml build configuration - https://github.com/yaml/pyyaml/blob/ee37f4653c08fc07aecff69cfd92848e6b1a540e/pyproject.toml

And for read the docs build, I could not find any ci step inside github action checks.yaml where I could tweak the requirement installation behaviour. Can you help me in locating the config for this?

Comment thread setup.cfg Resolved
@uniqueg

uniqueg commented Oct 3, 2023 •

Copy link
Copy Markdown
Member

@uniqueg we cannot force the build requirement of cython<3.0.0 in requirements.txt because pip isolates the build environment for each package that is installed. So even if we have installed the correct version of cython, it will try to use the latest version for building pyyaml, because they have not provided any version constraints in their build configuration.

ref - https://pip.pypa.io/en/stable/reference/build-system/pyproject-toml/

For building packages using this interface, pip uses an isolated environment. That is, pip will install build-time Python dependencies in a temporary directory which will be added to sys.path for the build commands. This ensures that build requirements are handled independently of the user’s runtime environment.
For example, a project that needs an older version of setuptools to build can still be installed, even if the user has an newer version installed (and without silently replacing that version).

pyyaml build configuration - https://github.com/yaml/pyyaml/blob/ee37f4653c08fc07aecff69cfd92848e6b1a540e/pyproject.toml

And for read the docs build, I could not find any ci step inside github action checks.yaml where I could tweak the requirement installation behaviour. Can you help me in locating the config for this?

Did you actually try that? Pip should resolve a list of packages that fulfills all the requirements, doesn't it?

About ReadTheDocs: That is the problem, you can't tweak the installation instructions, as far as I know. You can just point to one or more requirements files. And that config is done on RtD itself, not in the CI.

@alohamora

Copy link
Copy Markdown
Contributor Author

Did you actually try that? Pip should resolve a list of packages that fulfills all the requirements, doesn't it?

Yes, I tried by creating a requirements.txt file as shown below

cython<3.0.0
foca==0.10.0  #pyyaml is installed as part of foca installation

However, pip still uses the latest version of cython for building pyyaml, the reason is that pip will resolve only runtime package dependencies as defined in requirements.txt. However, cython is a build time dependency, which is only used to compile pyyaml, and as mentioned above, pip isolates the build environment for each package that is being installed, therefore it will not use system installed cython version.

That is the reason why I had to install pyyaml with the flag --no-build-isolation so that pip uses the installed cython version instead.

This error should be auto resolved if we upgrade to latest foca version (0.12.1), since it uses pyyaml==6.0.1 which is compatible with latest cython version.
Let me know if we should push the foca version upgrade first, because. I as per the diff of foca, there is no change in contracts/functionality as discussed on slack as well. Foca diff - elixir-cloud-aai/foca@v0.10.0...v0.12.1

@uniqueg

uniqueg commented Oct 4, 2023

Copy link
Copy Markdown
Member

Okay, thanks for the detailed explanation - now it makes sense to me.

Hmm, I would say it depends how much work you have put into this that you would need to redo if upgrading to the latest FOCA version first. If it is essentially only rerunning black, then yes, I would much prefer that over merging a failing PR.

If you'd have to redo a lot of work, let's bite that bullet.

@alohamora

alohamora commented Oct 5, 2023 •

Copy link
Copy Markdown
Contributor Author

I wouldn't have to redo any of my changes since the changelog of the foca upgrade only has one change, i.e adding the feature for running celery jobs.
and cloud registry currently doesn't use celery jobs, so we will just have to update the requirement, and it should work as it is.
changelog for reference - elixir-cloud-aai/foca@v0.10.0...v0.12.1

will share the PR for the foca upgrade today.

@alohamora

Copy link
Copy Markdown
Contributor Author

@uniqueg all tests have now passed, can you please review this PR again please

@uniqueg uniqueg changed the title ci: enable formatting check with black ci: check format with black Oct 19, 2023

@uniqueg uniqueg left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For consistency with all other code bases, I think I'd prefer a line length of 79.

Changed my mind

@uniqueg
uniqueg merged commit dc32e2a into dev Oct 19, 2023
@uniqueg
uniqueg deleted the enable-black-formatting branch October 19, 2023 13:20
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.

Standardize formatting for codebase using Black

3 participants