Skip to content

Commit 36454d3

Browse files
ftgoktasDooruk
andauthored
R2D2 v3 Adaptation (#618)
* Script to setup new r2d2 credentials * Create a new swell task to test new r2d2 * Adapt get_observations to new R2D2 * Remove exit() * Add r2d2 configs (#318) * Update swell tasks to new R2D2 (#318) * Update r2d2 version of save obs diagnostics #318 * Remove unused files #318 * Create r2d2 file register script #318 * Add scripts for manual setup for R2D2 #318 * Clean up files (#318) * Clean up the files (#318) * Update Python coding norms (#318) * Fix pycode styles * Remove redundant lines * Load R2D2 credentials under TaskBase (#318) * Load credentials under create R2D2 config (#318) * make R2D2 host/compiler detection support dynamic (#318) * Add docs for credential setup (#318) * Update r2d2_config for cascade (#318) * Move credentials under create_task (#318) * Move scripts under utilities (#318) * Fix pylint errors * Fix AttributeError when fetching bias correction files (#318) * Fix bias correction arguments (#318) * Fix bias correction argument (#318) * Add file type argument (#318) * Fix bias correction ingest * Improve file extension support * Add logging * Fix bias coefficient ingestion * Go back to existing bias naming convention * Use JCSDA enums for bias files * Improve logging * Fix code style * extend exclude list to ignore venv and build directories * Change the script name register_files with ingest_files * Fix logger * Fix string literal * Moved readme to docs * Fix pycode style * Remove redundant lines * Make the comment more generic * Add readme for ingest_files.py (#318) * Update src/swell/deployment/platforms/nccs_discover_sles15/r2d2_config.yaml Co-authored-by: Doruk Ardağ <38666458+Dooruk@users.noreply.github.com> * Remove redundant loging Co-authored-by: Doruk Ardağ <38666458+Dooruk@users.noreply.github.com> * Remove redundant logging * Remove unnecessary statements * Bump version to 1.11.0 * Bump version to 1.20.0 * Add how to register experiments to readme * Upgrade r2d2-client (#618) * Add register experiment to readme * r2d2 v3 turnoffrestart (#653) --------- Co-authored-by: Doruk Ardağ <38666458+Dooruk@users.noreply.github.com>
1 parent c05eed8 commit 36454d3

File tree

22 files changed

+1610
-152
lines changed

22 files changed

+1610
-152
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,8 @@ dmypy.json
136136
# Pyre type checker
137137
.pyre/
138138
*.egg-info
139+
140+
# R2D2 credentials
141+
r2d2_credentials.yaml
142+
**/r2d2_credentials.yaml
143+
.swell/r2d2_credentials.yaml
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# R2D2 v3 Credentials Configuration
2+
3+
This document explains how to configure R2D2 v3 credentials for SWELL workflows.
4+
5+
## Overview
6+
7+
SWELL now uses R2D2 v3 for metadata-driven data storage and retrieval. R2D2 v3 requires authentication credentials to access the centralized API. SWELL automatically loads these credentials from a YAML configuration file.
8+
9+
## Quick Setup
10+
11+
1. **Create the credentials directory:**
12+
```bash
13+
mkdir -p ~/.swell
14+
```
15+
16+
2. **Create the credentials file:**
17+
```bash
18+
cp /path/to/swell/r2d2_credentials.yaml ~/.swell/r2d2_credentials.yaml
19+
```
20+
21+
3. **Edit with your credentials:**
22+
```bash
23+
vim ~/.swell/r2d2_credentials.yaml
24+
```
25+
26+
4. **Set secure permissions:**
27+
```bash
28+
chmod 600 ~/.swell/r2d2_credentials.yaml
29+
```
30+
31+
## Credentials File Format
32+
33+
Create `~/.swell/r2d2_credentials.yaml` with the following structure:
34+
35+
```yaml
36+
# R2D2 v3 credentials file
37+
# Save this as ~/.swell/r2d2_credentials.yaml
38+
# Set permissions: chmod 600 ~/.swell/r2d2_credentials.yaml
39+
40+
# Required credentials
41+
user: your_username # Your R2D2 username
42+
api_key: your_api_key # Your R2D2 API key
43+
44+
# Platform-specific values (automatically determined by SWELL with an option to use YAML-first)
45+
# host: discover-gmao # Automatically set based on platform
46+
# compiler: intel # Automatically set based on platform
47+
48+
```
49+
50+
## Required Fields
51+
52+
| Field | Description | Example |
53+
|-------|-------------|---------|
54+
| `user` | Your R2D2 username | `jdoe` |
55+
| `api_key` | Your R2D2 API authentication key | `abcd1234-ef56-7890-abcd-1234567890ab` |
56+
57+
## Platform-Specific Fields (Automatically Set)
58+
59+
| Field | Description | NCCS Discover Value |
60+
|-------|-------------|---------------------|
61+
| `host` | Compute host identifier | `discover-gmao` |
62+
| `compiler` | Compiler type used | `intel` |
63+
64+
**Important**: `host` and `compiler` are automatically determined by SWELL based on your platform configuration. You can also set these manually in your credentials file.
65+
66+
### Loading Precedence
67+
68+
The credential loading follows this priority order:
69+
70+
1. **Environment Variables** (highest priority)
71+
2. **YAML Configuration File**
72+
3. **Platform Detection** (for host/compiler only)
73+
74+
**For host and compiler specifically:**
75+
- YAML `host`/`compiler` values override platform detection
76+
- Platform detection is used as fallback when not specified in YAML
77+
78+
### Platform-Specific Configuration
79+
80+
SWELL automatically determines `host` and `compiler` based on your platform:
81+
82+
| Platform | R2D2 Host | R2D2 Compiler | Notes |
83+
|----------|-----------|---------------|-------|
84+
| `nccs_discover_sles15` | `discover-gmao` | `intel` | NCCS Discover SLES15 |
85+
| `nccs_discover_cascade` | `discover-gmao` | `intel` | NCCS Discover Cascade |
86+
<!-- | `aws` | `aws-gmao` | `intel` | AWS cloud platform |
87+
| `generic` | `None` | `None` | Fallback to YAML/env vars | -->
88+
89+
90+
## Environment Variables Set
91+
92+
When loaded, the following environment variables are set:
93+
94+
- `R2D2_USER`: Your R2D2 username
95+
- `R2D2_API_KEY`: Your R2D2 API key
96+
- `R2D2_HOST`: Compute host name
97+
- `R2D2_COMPILER`: Compiler type
98+
<!-- - `R2D2_SERVER_HOST`: (Optional) API server override
99+
- `R2D2_SERVER_PORT`: (Optional) API server port override -->
100+

pycodestyle.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
max-line-length = 100
99
indent-size = 4
1010
statistics = True
11-
exclude = ._*, build, .venv
11+
exclude = ._*, build, .venv, venv, .git, __pycache__, .tox, .eggs, *.egg-info, dist
12+

r2d2_credentials.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# R2D2 v3 credentials file
2+
# Save this as ~/.swell/r2d2_credentials.yaml
3+
# Set permissions: chmod 600 ~/.swell/r2d2_credentials.yaml
4+
5+
# R2D2 v3 API credentials
6+
user: your_username
7+
api_key: your_api_key_here
8+
9+
# Platform configuration
10+
host: discover-gmao
11+
compiler: intel
12+
13+

src/swell/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
repo_directory = os.path.dirname(__file__)
1010

1111
# Set the version for swell
12-
__version__ = '1.10.0'
12+
__version__ = '1.20.0'

src/swell/deployment/platforms/nccs_discover_cascade/modules

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ module load other/mepo
3737
# Load r2d2 modules
3838
# -----------------
3939
module use -a /discover/nobackup/projects/gmao/advda/JediOpt/modulefiles/core
40-
module load solo/sles15_skylab9
41-
module load py-boto3
42-
module load r2d2/sles15_spack19
40+
module load r2d2-client/112025
4341

4442
# Load eva and jedi_bundle
4543
# ------------------------
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
databases:
2-
32
${USER}:
43
class: LocalDB
54
root: {{r2d2_local_path}}
65
cache_fetch: false
76

8-
gmao-shared:
9-
class: LocalDB
10-
root: /discover/nobackup/projects/gmao/advda/R2D2DataStore/Shared
11-
cache_fetch: false
7+
# v3 API configuration (for centralized nccs-gmao data)
8+
data_hub: nccs-gmao
9+
data_store: r2d2-experiments-nccs-gmao
10+
compute_host: discover-gmao-intel
1211

13-
# when fetching data, in which order should the databases accessed?
12+
# Fetch order: try local first, then API
1413
fetch_order:
1514
- ${USER}
16-
- gmao-shared
1715

18-
# when storing data, in which order should the databases accessed?
19-
store_order:
20-
- ${USER}
16+
# Optional: credentials file for v3 API authentication
17+
# credentials_file: ~/.swell/swell-r2d2-credentials.yaml
2118

19+
# Cache settings
2220
cache_name: ${USER}
21+
cache_fetch: false

src/swell/deployment/platforms/nccs_discover_sles15/modules

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ module load other/mepo
3737
# Load r2d2 modules
3838
# -----------------
3939
module use -a /discover/nobackup/projects/gmao/advda/JediOpt/modulefiles/core
40-
module load solo/sles15_skylab9
41-
module load py-boto3
42-
module load r2d2/sles15_spack19
40+
module load r2d2-client/112025
4341

4442
# Load eva and jedi_bundle
4543
# ------------------------
4644
module load eva/sles15_milan_1.6.5
4745
module load jedi_bundle/sles15_skylab9
4846

47+
# Remove any r2d2 v2 paths from PYTHONPATH to prevent conflicts
48+
export PYTHONPATH=$(echo $PYTHONPATH | tr ':' '\n' | grep -v "/r2d2/sles15_spack19/" | tr '\n' ':' | sed 's/:$//')
49+
4950
# Set the swell paths
5051
# -------------------
5152
PATH={{swell_bin_path}}:$PATH
@@ -57,3 +58,4 @@ ulimit -S -s unlimited
5758
ulimit -S -v unlimited
5859
umask 022
5960

61+
Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
databases:
2-
32
${USER}:
43
class: LocalDB
54
root: {{r2d2_local_path}}
65
cache_fetch: false
76

8-
gmao-shared:
9-
class: LocalDB
10-
root: /discover/nobackup/projects/gmao/advda/R2D2DataStore/Shared
11-
cache_fetch: false
7+
# v3 API configuration (for centralized nccs-gmao data)
8+
data_hub: nccs-gmao
9+
data_store: r2d2-experiments-nccs-gmao
10+
compute_host: discover-gmao-intel
1211

13-
# when fetching data, in which order should the databases accessed?
12+
# Fetch order: try local first, then API
1413
fetch_order:
1514
- ${USER}
16-
- gmao-shared
1715

18-
# when storing data, in which order should the databases accessed?
19-
store_order:
20-
- ${USER}
16+
# Optional: credentials file for v3 API authentication
17+
# credentials_file: ~/.swell/swell-r2d2-credentials.yaml
2118

19+
# Cache settings
2220
cache_name: ${USER}
21+
cache_fetch: false

src/swell/suites/3dfgat_cycle/flow.cylc

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,8 @@
7777
LinkGeosOutput-{{model_component}} => GenerateBClimatology-{{model_component}}
7878

7979
# Data assimilation preperation
80-
GetObservations-{{model_component}}
81-
GenerateBClimatologyByLinking-{{model_component}} :fail? => GenerateBClimatology-{{model_component}}
82-
83-
LinkGeosOutput-{{model_component}} => RunJediFgatExecutable-{{model_component}}
8480
StageJediCycle-{{model_component}} => RunJediFgatExecutable-{{model_component}}
85-
GenerateBClimatologyByLinking-{{model_component}}? | GenerateBClimatology-{{model_component}} => RunJediFgatExecutable-{{model_component}}
81+
GenerateBClimatology-{{model_component}} => RunJediFgatExecutable-{{model_component}}
8682
GetObservations-{{model_component}} => RunJediFgatExecutable-{{model_component}}
8783

8884
# Run analysis diagnostics
@@ -94,14 +90,17 @@
9490
RunJediFgatExecutable-{{model_component}} => EvaIncrement-{{model_component}}
9591
{% if 'cice6' in models[model_component]["marine_models"] %}
9692
PrepareAnalysis-{{model_component}} => RunJediConvertStateSoca2ciceExecutable-{{model_component}}
97-
RunJediConvertStateSoca2ciceExecutable-{{model_component}} => SaveRestart-{{model_component}}
93+
# RunJediConvertStateSoca2ciceExecutable-{{model_component}} => SaveRestart-{{model_component}}
94+
RunJediConvertStateSoca2ciceExecutable-{{model_component}} => MoveDaRestart-{{model_component}}
9895
RunJediConvertStateSoca2ciceExecutable-{{model_component}} => CleanCycle-{{model_component}}
9996
{% else %}
100-
PrepareAnalysis-{{model_component}} => SaveRestart-{{model_component}}
97+
# PrepareAnalysis-{{model_component}} => SaveRestart-{{model_component}}
98+
PrepareAnalysis-{{model_component}} => MoveDaRestart-{{model_component}}
10199
{% endif %}
102100

101+
# Temporarily disable saving restarts
103102
# Move restart to next cycle
104-
SaveRestart-{{model_component}} => MoveDaRestart-{{model_component}}
103+
# SaveRestart-{{model_component}} => MoveDaRestart-{{model_component}}
105104

106105
# Save analysis output
107106
# RunJediFgatExecutable-{{model_component}} => SaveAnalysis-{{model_component}}
@@ -192,9 +191,6 @@
192191
[[MoveDaRestart-{{model_component}}]]
193192
script = "swell task MoveDaRestart $config -d $datetime -m {{model_component}}"
194193

195-
[[SaveRestart-{{model_component}}]]
196-
script = "swell task SaveRestart $config -d $datetime -m {{model_component}}"
197-
198194
[[StageJedi-{{model_component}}]]
199195
script = "swell task StageJedi $config -m {{model_component}}"
200196

@@ -213,9 +209,6 @@
213209
--{{key}} = {{value}}
214210
{%- endfor %}
215211

216-
[[GenerateBClimatologyByLinking-{{model_component}}]]
217-
script = "swell task GenerateBClimatologyByLinking $config -d $datetime -m {{model_component}}"
218-
219212
{% if 'cice6' in models["geos_marine"]["marine_models"] %}
220213

221214
[[RunJediConvertStateSoca2ciceExecutable-{{model_component}}]]
@@ -253,8 +246,8 @@
253246
--{{key}} = {{value}}
254247
{%- endfor %}
255248

256-
[[SaveRestart-{{model_component}}]]
257-
script = "swell task SaveRestart $config -d $datetime -m {{model_component}}"
249+
# [[SaveRestart-{{model_component}}]]
250+
# script = "swell task SaveRestart $config -d $datetime -m {{model_component}}"
258251

259252
[[SaveObsDiags-{{model_component}}]]
260253
script = "swell task SaveObsDiags $config -d $datetime -m {{model_component}}"

0 commit comments

Comments
 (0)