Skip to content
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

Feature/r2d2v2 #186

Draft
wants to merge 35 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6f8faf8
First commit: Updates to the major API calls.
Apr 11, 2023
8af1da6
indentations
Apr 12, 2023
22b1092
update modules file
danholdaway May 2, 2023
ae1a729
Merge branch 'develop' into feature/r2d2v2-dan
danholdaway May 2, 2023
3f3052f
remove r2d2 config file
danholdaway May 2, 2023
8dbeb35
remove r2d2 from setup
danholdaway May 2, 2023
46ec993
tasks
tariqhamzeyssai Jun 27, 2023
a959ec5
file extension, make target dir, remove fetch data_store parameter
tariqhamzeyssai Jun 28, 2023
36d8825
MOM.res domain and take set of target_files from get_tlapse_files()
tariqhamzeyssai Jul 11, 2023
d158b8e
Merge branch 'develop' into feature/r2d2v2
tariqhamzeyssai Jul 14, 2023
9a1fe48
remove obs_process_setup.py
tariqhamzeyssai Jul 14, 2023
e7d11e2
window_length and variable name adjustments. Get, Hofx, Save all tested.
tariqhamzeyssai Jul 17, 2023
7fe625c
begin pep8 fixes
tariqhamzeyssai Jul 17, 2023
cf9ffa5
more pep8 fixes
tariqhamzeyssai Jul 17, 2023
234d5d7
a couple more pep8 fixes
tariqhamzeyssai Jul 17, 2023
457734a
modify questions in 3 different places, not tested yet
tariqhamzeyssai Jul 25, 2023
b57480f
Move store and fetch into a util file in which lists of data_stores a…
tariqhamzeyssai Jul 26, 2023
6cecb0a
pep8 fixes
tariqhamzeyssai Jul 26, 2023
c7a42dd
missed a pep8
tariqhamzeyssai Jul 26, 2023
f6c0a2e
typos. HOFX TESTED with new config scheme
tariqhamzeyssai Jul 26, 2023
d9d13c8
Add logging and fix yamls. Everything is tested for 2020 batch of data.
tariqhamzeyssai Jul 27, 2023
b821d09
just some yaml work for other suites
tariqhamzeyssai Aug 1, 2023
92ea088
move domain from atmosphere to ocean yaml
tariqhamzeyssai Aug 1, 2023
e50277b
Stop the fetch loop if we encounter any unexpected error
tariqhamzeyssai Aug 2, 2023
8c897af
pep8
tariqhamzeyssai Aug 2, 2023
7cb91ea
f strings
tariqhamzeyssai Aug 8, 2023
add67f9
Merge branch 'develop' into feature/r2d2v2
danholdaway Aug 15, 2023
67849be
YAML fixes to get code test passing
danholdaway Aug 15, 2023
b016b41
test info back to off
danholdaway Aug 15, 2023
4847732
add 'discover' to data_store names in nccs/discover/task_questions.yaml
tariqhamzeyssai Aug 22, 2023
b6ed172
bool -> boolean
tariqhamzeyssai Aug 24, 2023
14c56a9
fix indent
tariqhamzeyssai Sep 1, 2023
a2c206c
adjust default provider in task questions
tariqhamzeyssai Sep 1, 2023
3a86a50
Merge branch 'develop' into feature/r2d2v2
danholdaway Sep 5, 2023
cfd6b09
Merge branch 'develop' into feature/r2d2v2
danholdaway Oct 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ geovals_experiment:
default_value: x0048-geovals

geovals_provider:
default_value: ncdiag
default_value: x0048-geovals

gradient_norm_reduction:
default_value: 10e-5
Expand Down Expand Up @@ -85,7 +85,7 @@ obs_experiment:
default_value: x0048

obs_provider:
default_value: ncdiag
default_value: x0048

observations:
default_value:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ fetch:
fc:
- file_type: MOM.res
filename: '{{cycle_dir}}/MOM6.res.{{local_background_time}}.nc'
domain: global
store:
fc:
- file_type: MOM.res
20 changes: 0 additions & 20 deletions src/swell/deployment/bin/swell_create_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from swell.deployment.prep_suite import prepare_cylc_suite_jinja2
from swell.swell_path import get_swell_path
from swell.utilities.dictionary import dict_get
from swell.utilities.jinja2 import template_string_jinja2
from swell.utilities.logger import Logger
from swell.utilities.welcome_message import write_welcome_message

Expand Down Expand Up @@ -70,25 +69,6 @@ def main(config_file):
if os.path.exists(os.path.join(swell_suite_path, 'eva')):
copy_eva_files(logger, swell_suite_path, exp_suite_path)

# Create R2D2 database file
# -------------------------
r2d2_local_path = dict_get(logger, experiment_dict, 'r2d2_local_path', None)
if r2d2_local_path is not None:
r2d2_conf_path = os.path.join(exp_suite_path, 'r2d2_config.yaml')

# Write R2D2_CONFIG to modules
with open(os.path.join(exp_suite_path, 'modules'), 'a') as module_file:
module_file.write(f'export R2D2_CONFIG={r2d2_conf_path}')

# Open the r2d2 file to dictionary
with open(r2d2_conf_path, 'r') as r2d2_file_open:
r2d2_file_str = r2d2_file_open.read()
r2d2_file_str = template_string_jinja2(logger, r2d2_file_str, experiment_dict)
r2d2_file_str = os.path.expandvars(r2d2_file_str)

with open(r2d2_conf_path, 'w') as r2d2_file_open:
r2d2_file_open.write(r2d2_file_str)

# Set the swell paths in the modules file and create csh versions
# ---------------------------------------------------------------
template_modules_file(logger, experiment_dict, exp_suite_path)
Expand Down
22 changes: 0 additions & 22 deletions src/swell/deployment/platforms/generic/r2d2_config.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions src/swell/deployment/platforms/generic/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ experiment_id:

experiment_root:
default_value: /home/${USER}/SwellExperiments

r2d2_local_path:
default_value: /home/${USER}/R2D2DataStore/Local
18 changes: 18 additions & 0 deletions src/swell/deployment/platforms/generic/task_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ geos_restarts_directory:
default_value:
- /home/geos/restarts

r2d2_fetch_datastores:
default_value:
- swell-r2d2-${USER}
- swell-r2d2-archive
- swell-r2d2
options:
- swell-r2d2-${USER}
- swell-r2d2-archive
- swell-r2d2

r2d2_store_datastores:
default_value:
- swell-r2d2-${USER}
- swell-r2d2
options:
- swell-r2d2-${USER}
- swell-r2d2

swell_static_files:
default_value: This would need to be provided by user

22 changes: 0 additions & 22 deletions src/swell/deployment/platforms/nccs_discover/r2d2_config.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
experiment_root:
default_value: /discover/nobackup/${USER}/SwellExperiments

r2d2_local_path:
default_value: /discover/nobackup/${USER}/R2D2DataStore/Local
18 changes: 18 additions & 0 deletions src/swell/deployment/platforms/nccs_discover/task_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,24 @@ geos_experiment_directory:
geos_restarts_directory:
default_value: restarts_20210620_000000

r2d2_fetch_datastores:
default_value:
- swell-r2d2-discover-${USER}
- swell-r2d2-discover-archive
- swell-r2d2-discover
options:
- swell-r2d2-discover-${USER}
- swell-r2d2-discover-archive
- swell-r2d2-discover

r2d2_store_datastores:
default_value:
- swell-r2d2-discover-${USER}
- swell-r2d2-discover
options:
- swell-r2d2-discover-${USER}
- swell-r2d2-discover

swell_static_files:
default_value: /discover/nobackup/drholdaw/SwellStaticFiles

13 changes: 6 additions & 7 deletions src/swell/deployment/prep_exp_dirs.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ def copy_platform_files(logger, exp_suite_path, platform=None):
swell_lib_path = get_swell_path()
platform_path = os.path.join(swell_lib_path, 'deployment', 'platforms', platform)

for s in ['modules', 'r2d2_config.yaml']:
src_file = os.path.split(s)[1]
src_path_file = os.path.join(platform_path, os.path.split(s)[0], src_file)
dst_path_file = os.path.join(exp_suite_path, '{}'.format(src_file))
if os.path.exists(src_path_file):
logger.trace('Copying {} to {}'.format(src_path_file, dst_path_file))
shutil.copy(src_path_file, dst_path_file)
src_path_file = os.path.join(platform_path, 'modules')
dst_path_file = os.path.join(exp_suite_path, 'modules')

if os.path.exists(src_path_file):
logger.trace('Copying {} to {}'.format(src_path_file, dst_path_file))
shutil.copy(src_path_file, dst_path_file)


# --------------------------------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/3dvar/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ runahead_limit:
prompt: Since this suite is non-cycling choose how many hours the workflow can run ahead?
type: string

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value: defer_to_model
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/3dvar_cycle/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ final_cycle_point:
prompt: What is the time of the final cycle (middle of the window)?
type: iso-datetime

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value: defer_to_model
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/convert_ncdiags/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ runahead_limit:
prompt: Since this suite is non-cycling choose how many hours the workflow can run ahead?
type: string

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value: defer_to_model
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/forecast_geos/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ final_cycle_point:
prompt: What is the time of the final cycle (middle of the window)?
type: iso-datetime

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value:
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/geosadas/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ final_cycle_point:
prompt: What is the time of the final cycle (middle of the window)?
type: iso-datetime

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value: defer_to_model
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/hofx/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ runahead_limit:
prompt: Since this suite is non-cycling choose how many hours the workflow can run ahead?
type: string

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value: defer_to_model
Expand Down
6 changes: 0 additions & 6 deletions src/swell/suites/ufo_testing/suite_questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ runahead_limit:
prompt: Since this suite is non-cycling choose how many hours the workflow can run ahead?
type: string

r2d2_local_path:
ask_question: False
default_value: defer_to_platform
prompt: Enter the path where R2D2 will store experiment output
type: string

cycle_times:
ask_question: True
default_value: defer_to_model
Expand Down
42 changes: 27 additions & 15 deletions src/swell/tasks/get_background.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

# --------------------------------------------------------------------------------------------------


from swell.tasks.base.task_base import taskBase
from swell.utilities.store_fetch import fetch

import isodate
import os
from r2d2 import fetch


# --------------------------------------------------------------------------------------------------

Expand Down Expand Up @@ -50,6 +48,12 @@ def execute(self):
window_offset = self.config.window_offset()
window_type = self.config.window_type()

r2d2_fetch_datastores = self.config.r2d2_fetch_datastores(['swell-r2d2-archive'])
r2d2_fetch_datastores = [r.replace("${USER}", os.getenv('USER'))
for r in r2d2_fetch_datastores]

self.logger.info("Fetching from R2D2 data_stores: " + ', '.join(r2d2_fetch_datastores))

# Get window parameters
local_background_time = self.da_window_params.local_background_time(window_offset,
window_type)
Expand Down Expand Up @@ -118,6 +122,9 @@ def execute(self):
# Get r2d2 dictionary
r2d2_dict = self.jedi_rendering.render_interface_model('r2d2')

# To force localhost r2d2
# os.environ['R2D2_HOST'] = 'localhost'

# Loop over fc
# ------------
for fc in r2d2_dict['fetch']['fc']:
Expand All @@ -126,6 +133,7 @@ def execute(self):
# --------------------
file_type = fc['file_type']
target_file_template = fc['filename']
domain = fc.get('domain', '')

# Loop over background steps
# --------------------
Expand All @@ -139,18 +147,22 @@ def execute(self):
# ---------------------------------------------------
target_file = background_time.strftime(target_file_template)

fetch(
date=forecast_start_time,
target_file=target_file,
model=r2d2_model_dict[model_component],
file_type=file_type,
fc_date_rendering='analysis',
step=bkg_step,
resolution=horizontal_resolution,
type='fc',
experiment=background_experiment)
target_dir = os.path.dirname(target_file)
os.makedirs(target_dir, exist_ok=True)

fetched_from = fetch(r2d2_fetch_datastores,
item='forecast',
target_file=target_file,
model=r2d2_model_dict[model_component],
experiment=background_experiment,
file_extension="nc",
resolution=horizontal_resolution,
domain=domain,
file_type=file_type,
step=bkg_step,
date=forecast_start_time)

self.logger.info("Fetched R2D2 data from " + fetched_from + " to " + target_file)

# Change permission
os.chmod(target_file, 0o644)

# --------------------------------------------------------------------------------------------------
Loading