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

Allow users to provide copying of optional files without failing. #41

Merged
merged 7 commits into from
Sep 11, 2024

Conversation

aerorahul
Copy link
Contributor

@aerorahul aerorahul commented Sep 11, 2024

Description
This PR extends the FileHandler copy method to allow users to specify if files to be copied are either required or optional.

This is done by introducing copy_req and copy_opt. By default copy == copy_req.

The use is same as before; simply use copy_opt instead of copy for copying optional files. If a file is not found, a warning will be presented. For copy or copy_req, the error will be fatal.

This PR additionally allows users to checkout and develop wxflow in a vscode workspace environment.

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Tests have been added to the extended functionality

  • pynorms
  • pytests

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 need updates to the documentation. I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • New and existing tests pass with my changes
  • Any dependent changes have been merged and published

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 73.07692% with 7 lines in your changes missing coverage. Please review.

Project coverage is 50.35%. Comparing base (e1ef697) to head (cd5fe76).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
src/wxflow/file_utils.py 73.07% 7 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #41      +/-   ##
===========================================
+ Coverage    50.12%   50.35%   +0.23%     
===========================================
  Files           18       18              
  Lines         1652     1672      +20     
  Branches       339      343       +4     
===========================================
+ Hits           828      842      +14     
- Misses         765      771       +6     
  Partials        59       59              

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

Copy link
Collaborator

@CoryMartin-NOAA CoryMartin-NOAA left a comment

Choose a reason for hiding this comment

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

Questions on possible stray files but the rest looks good

@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

are these vscode files supposed to be committed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They should be. There is nothing here that is user specific.

import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../src')))
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this file needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. It tells the package where the src is in relation to the tests. Some packages do not keep code under src/app, but directly at app/

Another use for this file is to provide test fixtures that are/could be used across tests. Eg. if test_a.py and test_c.py needs something that is common, it can be a pytest fixture defined in conftest.py.

Copy link
Contributor

@DavidNew-NOAA DavidNew-NOAA left a comment

Choose a reason for hiding this comment

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

Looks good. See comments

src/wxflow/file_utils.py Outdated Show resolved Hide resolved
@@ -35,15 +38,25 @@ def sync(self):
Method to execute bulk actions on files described in the configuration
"""
sync_factory = {
'copy': self._copy_files,
'copy': self.copy_req,
'copy_req': self.copy_req,
Copy link
Contributor

Choose a reason for hiding this comment

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

copy and copy_req seems redundant since their behavior is the same. Why not just have copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I kept the distinction for clarity. If it were my choice, I would deprecate copy and make it explicit copy_req so it becomes clear.
Currently, we need to keep copy since that will break existing use.

Copy link
Contributor

Choose a reason for hiding this comment

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

In that case, I would suggest comments to indicate that copy is moving towards deprecation and shouldn't be used in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. If that is the consensus from the team, we can make that happen.
I will make a comment that copy will be deprecated by XYZ, and users should use copy_req instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Co-authored-by: DavidNew-NOAA <134300700+DavidNew-NOAA@users.noreply.github.com>
Copy link
Collaborator

@DavidHuber-NOAA DavidHuber-NOAA left a comment

Choose a reason for hiding this comment

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

Looks good, thanks @aerorahul!

@aerorahul aerorahul merged commit 799d55b into develop Sep 11, 2024
15 checks passed
@aerorahul aerorahul deleted the feature/copy_optional branch September 11, 2024 16: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.

4 participants