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

Issue 501 os to pathlib #1017

Closed
wants to merge 90 commits into from
Closed

Issue 501 os to pathlib #1017

wants to merge 90 commits into from

Conversation

finozzifa
Copy link
Contributor

@finozzifa finozzifa commented Apr 30, 2024

Closes # (if applicable).

Issue #501

Changes proposed in this Pull Request

The PR aims at replacing the os module with the pathlib module

Checklist

  • I consent to the release of this PR's code under the AGPLv3 license and non-code contributions under CC0-1.0 and CC-BY-4.0.
  • I tested my contribution locally and it seems to work fine.
  • Code and workflow changes are sufficiently documented.
  • Newly introduced dependencies are added to envs/environment.yaml and doc/requirements.txt.
  • Changes in configuration options are added in all of config.default.yaml and config.tutorial.yaml.
  • Add a test config or line additions to test/ (note tests are changing the config.tutorial.yaml)
  • Changes in configuration options are also documented in doc/configtables/*.csv and line references are adjusted in doc/configuration.rst and doc/tutorial.rst.
  • A note for the release notes doc/release_notes.rst is amended in the format of previous release notes, including reference to the requested PR.

finozzifa and others added 27 commits April 25, 2024 07:58
@finozzifa
Copy link
Contributor Author

mmm tests were ok when I executed them locally. I need to figure out what's the matter. Apologies for the failing pipelines.

@finozzifa
Copy link
Contributor Author

finozzifa commented May 14, 2024

Hi all,

please find below a recap of the changes I performed in this PR.

I tried my best to include all of your suggestions and recommendations. If I missed some, I apologize and I will include them as soon as possible.

### Recap of the changes

  1. The os module has been replaced with the pathlib module. There are still a few os-module-calls in build_natura_raster.py (this is because there is no pathlib alternative for os.walk) and in the _helpers.py

  2. As mentioned before, I have introduced an abstraction of the path methods. Such methods are available in the _helpers.py script. In fact, whenever I see lines of code that repeat themselfs several times, I try to create methods that implement such lines of code and that can be separately unit-tested. In this was I can ensure consistency and make future changes easier. Instead of tracing throughout the code each invocation of (say) os.path.basename(), I just need to modify once the method where such line is implemented. I believe that in this way, code reviews, code merges and further code expansions will be easier, as we can rely on soundproof methods that we have unit-tested.

  3. I have introduced dedicated unit tests for the path methods I coded in the _helpers.py. As of now, these unit tests are NOT executed as part of the CI/CD pipelines.

### Possible spin-offs

  1. It would nice to push these modifications a bit further, so that the dependency on the os and pathlib modules is explicit just in the _helpers.py script.

  2. It would nice to include the execution of the unit tests in the CI/CD pipeline, as already done for the framework repository

I thank you in advance for your comments in reviewing this PR :)

Fabrizio

@finozzifa finozzifa closed this Jun 5, 2024
@davide-f davide-f reopened this Aug 1, 2024
@finozzifa finozzifa closed this by deleting the head repository Sep 27, 2024
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.

5 participants