Skip to content

Commit

Permalink
some review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-seaice committed Jul 29, 2024
1 parent 6fdeb69 commit c052859
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ When contributing scripts to this repo, please follow these guidelines where it
- [x] Include documentation with your script. For example, a README explaining what the script is for, how to use it, what it can/can't do etc.
- [x] Any outputs from your script should include metadata that allows someone in the future to track down the exact version of the script used to create that output. Any easy way to do this is to include as metadata the url and commit hash of the script on GitHub. See existing scripts for examples of how to do this.
- [x] Consider including information about the dependencies or environment required to run your script, e.g. a conda-lock file describing your conda environment.

Python scripts are formatted using the [black formatter](https://github.com/psf/black). This is enforced using a github action running on pull requests. You will need to have _pre-commit_ and _black_ installed in your python environment. It is included in the _conda/analysis_ enviornments in _hh5_, otherwise it can be installed through pip or conda. Then run `pre-commit install` once to ensure your commits have black run on them before committing.
19 changes: 9 additions & 10 deletions payu/archive_scripts/build_intake_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# - conda/analysis

from access_nri_intake.source import builders
from payu.metadata import Metadata
import os

from pathlib import Path
Expand All @@ -32,14 +33,7 @@
builder.invalid_assets

# Get experiment uuid
# follows https://github.com/payu-org/payu/blob/ef55e93fe23fcde19024479c0dc4112dcdf6603f/payu/metadata.py#L90
metadata_filename = Path(METADATA_FILENAME)
if metadata_filename.exists():
metadata = CommentedMap()
metadata = YAML().load(metadata_filename)
uuid = metadata.get(UUID_FIELD, None)
else:
warn(f"{METADATA_FILENAME} not found in archive folder")
uuid = Metadata(laboratory_archive_path="archive/").uuid

# Check git status of this .py file
this_file = os.path.normpath(__file__)
Expand All @@ -49,9 +43,14 @@
# Get string "Created using $file: $command"
provenance = get_provenance_metadata(this_file, runcmd)

if uuid:
description = f"intake-esm datastore for experiment {uuid}, in folder {os.getcwd()}. {provenance}. (md5 hash: {md5sum(this_file)})"
else:
description = f"intake-esm datastore for experiment in folder {os.getcwd()}. {provenance}. (md5 hash: {md5sum(this_file)})"

# Save the datastore to a file (json)
builder.save(
name=f"intake_datastore_{uuid[0:8]}",
description=f"intake_datastore for experiment {uuid}, in folder {os.getcwd()}. {provenance}. (md5 hash: {md5sum(this_file)})",
name=f"intake_esm_ds",
description=description,
directory="archive/",
)

0 comments on commit c052859

Please sign in to comment.