Skip to content

Move PYTHONPATH configuration from load_modules.sh to J-Jobs that call Python scripts#4564

Merged
DavidHuber-NOAA merged 10 commits intodevelopfrom
copilot/remove-pythonpath-from-load-modules
Feb 18, 2026
Merged

Move PYTHONPATH configuration from load_modules.sh to J-Jobs that call Python scripts#4564
DavidHuber-NOAA merged 10 commits intodevelopfrom
copilot/remove-pythonpath-from-load-modules

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

✅ Move PYTHONPATH configuration from load_modules.sh to J-Jobs that call Python scripts

Summary

Successfully moved PYTHONPATH configuration from centralized setup scripts to individual J-Job files. Each job that calls Python execution scripts sets only the paths it needs, with all paths pointing to USHglobal (ush/python) as required. The workflow setup script (gw_setup.sh) is unchanged from develop.

Acceptance Criteria Status

  • Criterion 1: load_modules.sh no longer sets PYTHONPATH explicitly (except UFSDA case for gdas.cd)
  • Criterion 2: PYTHONPATH is set in each J-Job that needs it (42 jobs with Python ex scripts)
  • Criterion 3: PYTHONPATH only contains paths needed for each job
  • Criterion 4: PYTHONPATH only points to USHglobal paths (ush/python) ✨
  • Criterion 5: Runtime testing pending (requires HPC environment)

Changes Made (50 files)

Setup Scripts (2):

  • dev/ush/load_modules.sh: Removed generic PYTHONPATH (lines 219-226)
  • sorc/link_workflow.sh: Added wxflow symlink to ush/python (lines 98-105)

Unchanged:

  • dev/ush/gw_setup.sh: No changes - remains in original develop state with PYTHONPATH set to sorc/wxflow/src

J-Jobs Updated (48 total, 42 with PYTHONPATH):

  • 42 Jobs calling Python execution scripts: Set ${HOMEgfs}/ush/python in PYTHONPATH
    • Including JGLOBAL_FORECAST (can call exglobal_forecast.py)
    • Including JGLOBAL_ATMOS_ANALYSIS_CALC (calls calcinc_gfs.py, calcanl_gfs.py)
  • 6 Jobs removed: Only use compath.py (prod_util utility), don't need PYTHONPATH
  • UFSDA Jobs: Continue using load_modules.sh for gdas.cd paths

Implementation Pattern

# J-Jobs that call Python execution scripts:
# Setup Python path for pygfs
PYTHONPATH="${HOMEgfs}/ush/python${PYTHONPATH:+:${PYTHONPATH}}"
export PYTHONPATH

Jobs without PYTHONPATH (don't call Python execution scripts):

  • JGDAS_ATMOS_GEMPAK_META_NCDC (uses compath.py from prod_util)
  • JGFS_ATMOS_CYCLONE_GENESIS (uses compath.py from prod_util)
  • JGFS_ATMOS_CYCLONE_TRACKER (uses compath.py from prod_util)
  • JGFS_ATMOS_FSU_GENESIS (uses compath.py from prod_util)
  • JGFS_ATMOS_GEMPAK_META (uses compath.py from prod_util)
  • JGLOBAL_ATMOS_CHGRES_GEN_CONTROL (calls shell script, not Python)

Key Change: wxflow Linking

The link_workflow.sh script creates a symlink:

ush/python/wxflow -> sorc/wxflow/src/wxflow

This allows J-Jobs to reference only ush/python while still accessing wxflow functionality.

Important Note: gw_setup.sh is unchanged from develop and retains its original PYTHONPATH configuration pointing to sorc/wxflow/src. This file is not modified as part of this PR.

Validation

  • ✅ Shellcheck passes (all modified files)
  • ✅ Bash syntax valid (all modified files)
  • ✅ shfmt formatting applied (all modified files)
  • ✅ No references to sorc/wxflow/src in J-Jobs
  • ✅ All paths in J-Jobs point to USHglobal (ush/python)
  • ✅ Only jobs calling Python ex scripts have PYTHONPATH (42 jobs)
  • ✅ Jobs using only compath.py don't have PYTHONPATH (6 jobs)
  • ✅ gw_setup.sh unchanged from develop (original PYTHONPATH preserved)
  • ✅ UFSDA-specific PYTHONPATH preserved

Testing Requirements

Runtime testing on HPC platforms (HERA, HERCULES, WCOSS2, Ursa, etc.) is needed to verify:

  • link_workflow.sh creates wxflow symlink successfully
  • gw_setup.sh works correctly with original PYTHONPATH configuration
  • All 42 Python jobs execute with ush/python PYTHONPATH
  • 6 jobs without PYTHONPATH work correctly (compath.py from prod_util)
  • No regression in job functionality
Original prompt

This section details on the original issue you should resolve

<issue_title>Set PYTHONPATH in the J-Job</issue_title>
<issue_description>### What new functionality do you need?

Currently, the PYTHONPATH is being declared in load_modules.sh. This needs to be removed and placed in each of the J-Jobs as needed.

Acceptance Criteria

  • load_modules.sh no longer sets PYTHONPATH explicitly (aside from what the loaded Python modules set)
  • PYTHONPATH is set in each J-Job that needs it and not in others
  • PYTHONPATH only contains the paths needed for the job
  • PYTHONPATH, when set in the J-Job, should only point to USHglobal paths (i.e. not to sorc)
  • All jobs run successfully

Suggest a solution (optional)

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: CoryMartin-NOAA <6354668+CoryMartin-NOAA@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove PYTHONPATH declaration from load_modules.sh Move PYTHONPATH configuration from load_modules.sh to individual J-Jobs Feb 17, 2026
@CoryMartin-NOAA
Copy link
Contributor

@copilot the issue explicitly says PYTHONPATH, when set in the J-Job, should only point to USHglobal paths (i.e. not to sorc) so we need to ensure that those paths are linked to ush/python as part of the link_workflow script.

- Modified link_workflow.sh to create symlink from sorc/wxflow/src/wxflow to ush/python/wxflow
- Updated 44 J-Jobs to remove sorc/wxflow/src from PYTHONPATH
- J-Jobs now only reference ${HOMEgfs}/ush/python in PYTHONPATH
- This satisfies acceptance criterion #4: PYTHONPATH only points to USHglobal paths

Co-authored-by: CoryMartin-NOAA <6354668+CoryMartin-NOAA@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot the issue explicitly says PYTHONPATH, when set in the J-Job, should only point to USHglobal paths (i.e. not to sorc) so we need to ensure that those paths are linked to ush/python as part of ...

Fixed in commit aba791f. The link_workflow.sh script now creates a symlink from sorc/wxflow/src/wxflow to ush/python/wxflow, and all 44 J-Jobs have been updated to use only ${HOMEgfs}/ush/python in PYTHONPATH. This satisfies acceptance criterion #4 - PYTHONPATH now only points to USHglobal paths.

Copilot AI changed the title Move PYTHONPATH configuration from load_modules.sh to individual J-Jobs Move PYTHONPATH configuration from load_modules.sh to individual J-Jobs using USHglobal paths Feb 17, 2026
@CoryMartin-NOAA
Copy link
Contributor

@copilot do all 46 j-jobs need the PYTHONPATH updated? Should it only be scripts that call python ex scripts?

- Removed PYTHONPATH from 6 J-Jobs that only use compath.py (a prod_util utility)
- These jobs don't call Python ex scripts and don't need PYTHONPATH:
  * JGDAS_ATMOS_GEMPAK_META_NCDC
  * JGFS_ATMOS_CYCLONE_GENESIS
  * JGFS_ATMOS_CYCLONE_TRACKER
  * JGFS_ATMOS_FSU_GENESIS
  * JGFS_ATMOS_GEMPAK_META
  * JGLOBAL_ATMOS_CHGRES_GEN_CONTROL (calls .sh script, not .py)
- Result: 40 J-Jobs with PYTHONPATH, all calling Python execution scripts

Co-authored-by: CoryMartin-NOAA <6354668+CoryMartin-NOAA@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 17, 2026

@copilot do all 46 j-jobs need the PYTHONPATH updated? Should it only be scripts that call python ex scripts?

Correct - PYTHONPATH should only be in scripts that call Python execution scripts. Fixed in commit 2b82f24. Removed PYTHONPATH from 6 J-Jobs that only use compath.py (a prod_util utility) or call shell scripts:

  • JGDAS_ATMOS_GEMPAK_META_NCDC
  • JGFS_ATMOS_CYCLONE_GENESIS
  • JGFS_ATMOS_CYCLONE_TRACKER
  • JGFS_ATMOS_FSU_GENESIS
  • JGFS_ATMOS_GEMPAK_META
  • JGLOBAL_ATMOS_CHGRES_GEN_CONTROL

Result: 40 J-Jobs have PYTHONPATH (all call Python ex scripts), 6 removed (don't need it).

Copilot AI changed the title Move PYTHONPATH configuration from load_modules.sh to individual J-Jobs using USHglobal paths Move PYTHONPATH configuration from load_modules.sh to J-Jobs that call Python scripts Feb 17, 2026
exit 1
fi

# Set up the PYTHONPATH to include wxflow from HOMEgfs
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot also add ush/python to PYTHONPATH here when this is removed, thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in commit 2ae1a08. Added PYTHONPATH="${HOMEgfs}/ush/python${PYTHONPATH:+:${PYTHONPATH}}" to gw_setup.sh so workflow setup scripts have access to pygfs and wxflow (via symlink in ush/python).

Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot we actually shouldn't change this file because the wxflow directory will have not yet been linked before anything is built and this is needed to build. So please revert all changes to this file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit b558efc. All PYTHONPATH changes to gw_setup.sh have been removed - the file is now in the same state as after ae0ce17 (no PYTHONPATH configuration). This is correct since gw_setup.sh runs during workflow setup/build, before link_workflow.sh creates the wxflow symlink.

Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot you misunderstood me, I want this file reverted to develop. We should not be changing it at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted to develop in commit 5c572ec. The file is now completely unchanged from its original state, including the PYTHONPATH configuration that points to sorc/wxflow/src. This file is no longer modified as part of this PR.

- Added PYTHONPATH="${HOMEgfs}/ush/python${PYTHONPATH:+:${PYTHONPATH}}" to gw_setup.sh
- This ensures workflow setup scripts have access to pygfs and wxflow (via symlink)
- Addresses review comment to add ush/python when removing sorc/wxflow/src reference

Co-authored-by: CoryMartin-NOAA <6354668+CoryMartin-NOAA@users.noreply.github.com>
Copilot AI changed the title Move PYTHONPATH configuration from load_modules.sh to J-Jobs that call Python scripts Move PYTHONPATH configuration from load_modules.sh to J-Jobs and workflow setup scripts Feb 17, 2026
- Reverted all PYTHONPATH changes to gw_setup.sh
- The wxflow symlink doesn't exist during workflow setup/build phase
- gw_setup.sh is used before link_workflow.sh creates the symlink
- File now has no PYTHONPATH configuration (same as ae0ce17)

Co-authored-by: CoryMartin-NOAA <6354668+CoryMartin-NOAA@users.noreply.github.com>
Copilot AI changed the title Move PYTHONPATH configuration from load_modules.sh to J-Jobs and workflow setup scripts Move PYTHONPATH configuration from load_modules.sh to J-Jobs that call Python scripts Feb 17, 2026
@CoryMartin-NOAA
Copy link
Contributor

Some of my tests on Ursa are looking good after one full cycle so I'm going to mark this ready for review. Will post details tomorrow AM and then we can use CI for more thorough testing.

@DavidHuber-NOAA
Copy link
Contributor

Approved pending successful tests on Ursa.

@CoryMartin-NOAA
Copy link
Contributor

Running the -G and -C tests on Ursa worked overnight. @DavidHuber-NOAA feel free to kick off testing on another machine but I think this is ready to go.

@DavidHuber-NOAA
Copy link
Contributor

Launching on C6.

@emcbot emcbot added CI-Gaeac6-Ready **CM use only** PR is ready for CI testing on Gaea C6 CI-Gaeac6-Building **Bot use only** CI testing is cloning/building on Gaea C6 CI-Gaeac6-Running **Bot use only** CI testing on Gaea C6 for this PR is in-progress and removed CI-Gaeac6-Ready **CM use only** PR is ready for CI testing on Gaea C6 CI-Gaeac6-Building **Bot use only** CI testing is cloning/building on Gaea C6 labels Feb 18, 2026
@emcbot
Copy link

emcbot commented Feb 18, 2026

C96C48mx500_S2SW_cyc_gfs FAILED on Gaeac6 (pipeline ID: 9221)

In directory: /gpfs/f6/drsa-precip3/world-shared/global/CI/GITLAB/pr_cases_4564_24f56a5c_9221/RUNTESTS/EXPDIR/C96C48mx500_S2SW_cyc_gfs_24f56a5c-9221

Error Log Files:


/gpfs/f6/drsa-precip3/world-shared/global/CI/GITLAB/pr_cases_4564_24f56a5c_9221/RUNTESTS/COMROOT/C96C48mx500_S2SW_cyc_gfs_24f56a5c-9221/logs/2021122100/gdas_arch_tar_gdas_restartb.log

View Error Logs: (gdas_arch_tar_gdas_restartb.log)

This failure was detected automatically by global-workflow's CI/CD Pipeline

@emcbot emcbot added CI-Gaeac6-Failed **Bot use only** CI testing on Gaea C6 for this PR has failed and removed CI-Gaeac6-Running **Bot use only** CI testing on Gaea C6 for this PR is in-progress labels Feb 18, 2026
@DavidHuber-NOAA
Copy link
Contributor

All tests passed on C6 except for archiving during the C96C48mx500_S2SW_cyc_gfs test. This is due to a transient drive dismounting issue ongoing on the platform. I think this is good to go now. Merging.

@DavidHuber-NOAA DavidHuber-NOAA added CI-Gaeac6-Passed (cm) Manual CI passed on Gaea C6 and removed CI-Gaeac6-Failed **Bot use only** CI testing on Gaea C6 for this PR has failed labels Feb 18, 2026
@DavidHuber-NOAA DavidHuber-NOAA merged commit 3b291f6 into develop Feb 18, 2026
7 checks passed
@CoryMartin-NOAA
Copy link
Contributor

Woohoo! I love a good AI PR that works with minimal intervention

CoryMartin-NOAA pushed a commit to CoryMartin-NOAA/global-workflow that referenced this pull request Feb 25, 2026
…l Python scripts (NOAA-EMC#4564)

Move PYTHONPATH configuration from load_modules.sh to J-Jobs that
call Python scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI-Gaeac6-Passed (cm) Manual CI passed on Gaea C6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set PYTHONPATH in the J-Job

7 participants