NOAA-EMC / wxflow

Tools for Weather Workflows
https://wxflow.readthedocs.io/en/latest
GNU Lesser General Public License v3.0
0 stars 7 forks source link

Add some methods and initialize task_config in task class #29

Closed DavidNew-NOAA closed 3 months ago

DavidNew-NOAA commented 3 months ago

Description

This PR causes the the "task_config" member AttrDict object to be created in the init method of the "Task" class. Previously, "task_config" has been created separately, but all applications that utilize the "Task" class expect "task_config" to exist, so it might as well be created at initialization. Example of task_config creation: https://github.com/NOAA-EMC/global-workflow/blob/67b833e0c7bc390865d453588b4609a1a7ede981/ush/python/pygfs/task/atm_analysis.py#L59

This PR also adds two class methods to the "Task" class:

  1. j2yaml_to_filehandler: Parses a Jinja2-templated YAML and then passes the resulting dictionary to the file wxflow FileHandler. This is a common task when staging files for various jobs that can be consolidated into a class method. Example: https://github.com/NOAA-EMC/global-workflow/blob/67b833e0c7bc390865d453588b4609a1a7ede981/ush/python/pygfs/task/atm_analysis.py#L78
  2. extend_task_config: Takes a dictionary or AttrDict object and merges it with the "task_config". This is a common task done when initializing Task objects. Example: https://github.com/NOAA-EMC/global-workflow/blob/67b833e0c7bc390865d453588b4609a1a7ede981/ush/python/pygfs/task/atm_analysis.py#L59

This PR is part of a broader refactoring of pygfs in the Global Workflow.

Type of change

How Has This Been Tested?

Checklist

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 25.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 47.91%. Comparing base (8406bee) to head (7b5f330). Report is 8 commits behind head on develop.

Files with missing lines Patch % Lines
src/wxflow/task.py 25.00% 12 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## develop #29 +/- ## =========================================== - Coverage 47.93% 47.91% -0.03% =========================================== Files 18 18 Lines 1650 1657 +7 Branches 335 336 +1 =========================================== + Hits 791 794 +3 - Misses 799 803 +4 Partials 60 60 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.