-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(local): Add MetOffice global asset (#125)
* feat(local): Add MetOffice global asset * style(api): Update AutomizationPolicy -> AutomationCondition * chore(env): Bump dagster versions * fix(api): Use newer dagster API naming * fix(ceda_global): Add file * fix(ceda_global): Use constants for folders
- Loading branch information
Showing
8 changed files
with
75 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,10 +1,15 @@ | ||
import dagster as dg | ||
|
||
from . import ceda_uk | ||
from . import ceda_uk, ceda_global | ||
|
||
uk_assets = dg.load_assets_from_modules( | ||
modules=[ceda_uk], | ||
group_name="ceda_uk", | ||
) | ||
|
||
all_assets: list[dg.AssetsDefinition] = [*uk_assets] | ||
global_assets = dg.load_assets_from_modules( | ||
modules=[ceda_global], | ||
group_name="ceda_global", | ||
) | ||
|
||
all_assets: list[dg.AssetsDefinition] = [*uk_assets, *global_assets] |
This file contains 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,52 @@ | ||
import dagster as dg | ||
import os | ||
from typing import Any | ||
import datetime as dt | ||
|
||
from dagster_docker import PipesDockerClient | ||
from constants import LOCATIONS_BY_ENVIRONMENT | ||
|
||
env = os.getenv("ENVIRONMENT", "local") | ||
ZARR_FOLDER = LOCATIONS_BY_ENVIRONMENT[env].NWP_ZARR_FOLDER | ||
|
||
@dg.asset( | ||
name="zarr_archive", | ||
key_prefix=["nwp", "ceda", "global"], | ||
metadata={ | ||
"archive_folder": dg.MetadataValue.text(f"{ZARR_FOLDER}/nwp/ceda/global"), | ||
"area": dg.MetadataValue.text("global"), | ||
"source": dg.MetadataValue.text("ceda"), | ||
}, | ||
compute_kind="download", | ||
op_tags={"dagster/max_runtime": int(60 * 100)}, | ||
partitions_def=dg.MonthlyPartitionsDefinition( | ||
start_date="2019-01-01", | ||
end_offset=-3, | ||
), | ||
) | ||
def ceda_global( | ||
context: dg.AssetExecutionContext, | ||
pipes_docker_client: PipesDockerClient, | ||
) -> Any: | ||
image: str = "ghcr.io/openclimatefix/nwp-consumer:devsjc-major-refactor" | ||
it: dt.datetime = context.partition_time_window.start | ||
return pipes_docker_client.run( | ||
image=image, | ||
command=[ | ||
"consume", | ||
"-y", | ||
str(it.year), | ||
"-m", | ||
str(it.month), | ||
], | ||
env={ | ||
"NWP_CONSUMER_MODEL_REPOSITORY": "ceda-metoffice-global", | ||
"NWP_CONSUMER_NOTIFICATION_REPOSITORY": "dagster-pipes", | ||
"CEDA_FTP_USER": os.environ["CEDA_FTP_USER"], | ||
"CEDA_FTP_PASSWORD": os.environ["CEDA_FTP_PASSWORD"], | ||
}, | ||
container_kwargs={ | ||
"volumes": [f"{ZARR_FOLDER}/nwp/ceda/global:/work"], | ||
}, | ||
context=context, | ||
).get_results() |
This file contains 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 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 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