Replace standardise_mom6_filenames.sh with a new script#133
Replace standardise_mom6_filenames.sh with a new script#133dougiesquire wants to merge 2 commits into
Conversation
43539cf to
1dcfe97
Compare
- Supports more than just annual timestamps (e.g. _2023_01_01) - Supports OM2 output as well
1dcfe97 to
c64e540
Compare
|
I've tested that this:
|
anton-seaice
left a comment
There was a problem hiding this comment.
Code review only - looks good to me
| basename = os.path.basename(path) | ||
|
|
||
| # Split the .nc extension | ||
| ext_match = re.match(r"^(.*?)(\.nc.*)$", basename) |
There was a problem hiding this comment.
I think the matches against things where there is anything(.*) after .nc, is that needed ?
Probably harmless even if not needed
There was a problem hiding this comment.
Yeah, we also want to match uncollated files e.g. *.nc.0001
| # Create files at the expected destination paths so there is something to protect | ||
| expected_paths = [standardised_path(p, s) for p, s in zip(original_paths, suffixes)] | ||
| for p in expected_paths: | ||
| Path(p).touch() |
There was a problem hiding this comment.
these files should probably be made in a fixture, otherwise they might impact later tests right ?
anyway, again you can say "no worse than the old method"
There was a problem hiding this comment.
This is using the pytest tmp_path fixture so I think it is safe. Files created in one tests tmp_path are invisible to others.
I think the chdir could be an issue if we weren't running this sequentially, but we are.
The new script:
Closes #132