Skip to content

Conversation

@noribeth-m
Copy link

I added in a code fix to driver.py to be able to read in a list of multiple sorted model output files from the YAML file.

Essentially, when reading the files from the YAML file, there are four different scenarios:

  1. If given a sorted list, assigns this list to self.files variable (change I added)
  2. If the string begins with 'example', it treats the input as an ID and fetches example files.
  3. If file path uses (*), then pulls files matching the pattern using glob and sorts.
  4. Checks for .txt files.

The last code change reads the list of model files given and prepares them for use in MELODIES-MONET.

@rschwant
Copy link
Collaborator

Can you upload an example of how users would do this with their yaml file since it is different from what is typically done? Not sure if this is useful, but we had been linking files like the scripts here for more complex workflows too. https://github.com/NCAR/MELODIES-MONET/blob/main/examples/submit_jobs/link_files_wrf.sh

@noribeth-m
Copy link
Author

Hi. An example of the YAML file can be seen here, under models: https://github.com/noribeth-m/pair_tempo/blob/main/yaml/control_tempo_l2_no2_cesm_fv_20240701.yaml

When I added this change to my code base initially, it was because I was getting a TypeError as "TypeError: expected str, bytes or os.PathLike object, not list", when I tried to input a list to the MELODIES-MONET YAML file, whether in brackets or as is in the linked YAML file. I was specifically testing a way to pair TEMPO data with model output in a quicker way and needed to have the previous and current day as a list for the model: https://github.com/noribeth-m/pair_tempo

_, extension = os.path.splitext(self.file_str)
if extension.lower() == '.txt':
with open(self.file_str,'r') as f:
self.files = f.read().split()
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this as a guard to avoid trying to .split() lists? In that case, should we be able to split list elements, or is that overkill?

Copy link
Author

Choose a reason for hiding this comment

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

No, this snippet is meant to generate a list of strings from a text file, if that is what's provided. It would split the content of the text file by whitespaces.

Co-authored-by: Pablo Lichtig <[email protected]>
@blychs
Copy link
Contributor

blychs commented Oct 7, 2025

Is there anything missing? I think this could be merged into develop. @noribeth-m, can you change the target branch? We should not merge this into main until the next develop to main is done.

@noribeth-m noribeth-m changed the base branch from main to develop October 7, 2025 20:27
@noribeth-m
Copy link
Author

@blychs I just changed the target branch to develop. I don't think there is anything else missing.

@blychs
Copy link
Contributor

blychs commented Oct 10, 2025

This needs approval by someone with write access. @rschwant, since you were the one looking at this before, what do you think?

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.

3 participants