-
Notifications
You must be signed in to change notification settings - Fork 7
Enable Swell to use GMAO AWS R2D2 server and S3 data store #734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ftgoktas
wants to merge
18
commits into
develop
Choose a base branch
from
feature/aws-datastore
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e2fb945
Create a doc to test AWS server
ftgoktas c924870
Create instructions
ftgoktas 0f70277
Add AWS credential configs
ftgoktas 42e1235
Update docs
ftgoktas 2363afa
Update docs
ftgoktas 6cbeae9
Fix tests
ftgoktas 152de31
Edit doc sections
ftgoktas 60844b8
Create a doc to test AWS server
ftgoktas 7c366d6
Create instructions
ftgoktas 0fe5b81
Add AWS credential configs
ftgoktas 4a8835e
Update docs
ftgoktas 5e4fdd0
Update docs
ftgoktas bede62e
Remove outdated comments
ftgoktas d9c6258
Fix typo (#733)
ftgoktas 2001b99
Merge remote-tracking branch 'origin/feature/aws-datastore' into feat…
ftgoktas 707cdd7
Fix codestyle (#733)
ftgoktas 61777b5
Merge branch 'develop' into feature/aws-datastore
ftgoktas d0a8d5a
Update docs and ingest obs dates (#733)
ftgoktas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| # Quick guide to test R2D2 server with Swell on Discover | ||
|
|
||
| [Test outside of Swell](#2-to-test-outside-of-swell) | ||
|
|
||
| ## 1. To test within Swell: | ||
|
|
||
| Make sure `~/.swell/r2d2_credentials.yaml` exists with your user/api_key/host/compiler and AWS credentials for S3 access. | ||
|
|
||
| #### a. Set ~/.swell/r2d2_credentials.yaml | ||
|
|
||
| ```bash | ||
| # R2D2 API credentials | ||
| user: <your_username> | ||
| api_key: <your_key> | ||
| r2d2_host: discover | ||
| r2d2_compiler: intel | ||
| r2d2_server_host: "<enter_ip_address>" | ||
| r2d2_server_port: "8080" | ||
|
|
||
| # For S3 access | ||
| aws_access_key_id : <access_key_id> | ||
| aws_secret_access_key : <secret_access_key> | ||
| aws_session_token : "<session_token>" | ||
|
|
||
| ``` | ||
|
|
||
| #### b. Quick test | ||
|
|
||
| Run `IngestObs` directly without launching a full workflow: | ||
|
|
||
| ```bash | ||
| # Create the experiment | ||
| swell create ingest_obs_marine | ||
|
|
||
| # Edit the generated experiment.yaml: | ||
| # - dry_run: false | ||
| # - obs_to_ingest: ['adt_cryosat2n'] | ||
|
|
||
| # Run the task | ||
| swell task IngestObs <experiment_root>/swell-ingest_obs/swell-ingest_obs-suite/experiment.yaml \ | ||
| -d 2021-07-02T06:00:00Z \ | ||
| -m geos_marine | ||
| ``` | ||
|
|
||
| ### Verify it is stored | ||
|
|
||
| ```python | ||
| python3 -c " | ||
| import r2d2 | ||
| results = r2d2.search( | ||
| item='observation', | ||
| observation_type='adt_cryosat2n', | ||
| window_start='20210702T060000Z', | ||
| window_length='PT6H' | ||
| ) | ||
| print(f'Found {len(results)} records') | ||
| for r in results: | ||
| print(r) | ||
| " | ||
| ``` | ||
|
|
||
| ### Test fetch | ||
|
|
||
| ```python | ||
| python3 -c " | ||
| import r2d2 | ||
| r2d2.fetch( | ||
| item='observation', | ||
| provider='odas', | ||
| observation_type='adt_cryosat2n', | ||
| file_extension='nc', | ||
| window_start='20210702T090000Z', | ||
| window_length='PT6H', | ||
| target_file='./test_fetch.nc' | ||
| ) | ||
| print('Fetch OK') | ||
| " | ||
| ``` | ||
|
|
||
| ### Full workflow test | ||
|
|
||
| ```bash | ||
| swell create ingest_obs_marine | ||
| # Edit experiment.yaml: dry_run: false | ||
| # Run the suite | ||
| swell launch /path/to/suite/swell-ingest_obs/swell-ingest_obs-suite | ||
| ``` | ||
|
|
||
| This runs `IngestObs` for every cycle time across the date range. | ||
|
|
||
| ## 2. To test outside of Swell: | ||
|
|
||
| #### a. Set up your environment | ||
|
|
||
| Copy or create the required scripts into your working directory: | ||
| - [load_r2d2.sh](../src/swell/utilities/scripts/load_r2d2.sh) | ||
| - [prod_setup_env.sh](../src/swell/utilities/scripts/prod_setup_env.sh) | ||
|
|
||
| Then source them to load R2D2 and set environment variables: | ||
|
|
||
| ```bash | ||
| source load_r2d2.sh | ||
| source prod_setup_env.sh | ||
| ``` | ||
|
|
||
| #### b. Configure AWS credentials: | ||
|
|
||
| Set up AWS credentials for S3 access. | ||
|
|
||
| ```bash | ||
| mkdir -p ~/.aws | ||
|
|
||
| cat >> ~/.aws/credentials << 'EOF' | ||
| [aws-us-east-1] | ||
| aws_access_key_id = ACCESS_KEY | ||
| aws_secret_access_key = SECRET_KEY | ||
| EOF | ||
|
|
||
| cat >> ~/.aws/config << 'EOF' | ||
| [profile aws-us-east-1] | ||
| region = us-east-1 | ||
| EOF | ||
| ``` | ||
|
|
||
| #### c. Test R2D2 store/fetch from Discover | ||
|
|
||
| ```bash | ||
| python3 << 'EOF' | ||
| import r2d2 | ||
|
|
||
| # Test metadata (API only) | ||
| print("Data hubs:") | ||
| for h in r2d2.search(item='data_hub'): | ||
| print(f" {h.get('name')} ({h.get('platform')})") | ||
|
|
||
| print("Data stores:") | ||
| for s in r2d2.search(item='data_store'): | ||
| print(f" {s.get('name')}") | ||
|
|
||
| print("Compute hosts:") | ||
| for c in r2d2.search(item='compute_host'): | ||
| print(f" {c.get('name')}") | ||
|
|
||
| # Test store (API + S3) | ||
| import tempfile, os | ||
| test_file = os.path.join(tempfile.gettempdir(), 'r2d2_test.txt') | ||
| with open(test_file, 'w') as f: | ||
| f.write("test from Discover\n") | ||
|
|
||
| r2d2.store( | ||
| item='observation', | ||
| provider='test', | ||
| observation_type='test_obs', | ||
| file_extension='txt', | ||
| window_start='20240101T120000Z', | ||
| window_length='PT6H', | ||
| source_file=test_file | ||
| ) | ||
| print("Store OK") | ||
|
|
||
| # Test fetch (API + S3) | ||
| fetch_file = os.path.join(tempfile.gettempdir(), 'r2d2_fetched.txt') | ||
| r2d2.fetch( | ||
| item='observation', | ||
| provider='test', | ||
| observation_type='test_obs', | ||
| file_extension='txt', | ||
| window_start='20240101T120000Z', | ||
| window_length='PT6H', | ||
| target_file=fetch_file | ||
| ) | ||
| print(f"Fetch OK: {open(fetch_file).read().strip()}") | ||
| EOF | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is this lind in
load_r2d2.sh?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It initializes the
spack-stackon Discover so that the subsequentmodule load r2d2-client/...command works. Is this alias (mod_swell) defined for you? I assume it's not for most people, so I'll need to change it.