-
-
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(sat): Monthly Zarr files (#129)
* feat(sat): Monthly Zarr files * feat(dags): Add satellite dag * fix(sat): Add files!
- Loading branch information
Showing
11 changed files
with
112 additions
and
190 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,11 +1,14 @@ | ||
from dagster import Definitions, load_assets_from_modules | ||
"""Definitions for the sat dagster code location.""" | ||
|
||
from sat import assets, jobs | ||
import dagster as dg | ||
|
||
from . import eumetsat | ||
|
||
all_assets = load_assets_from_modules([assets]) | ||
all_assets: list[dg.AssetsDefinition] = [ | ||
*eumetsat.all_assets, | ||
] | ||
|
||
all_jobs: list[dg.JobDefinition] = [] | ||
|
||
all_schedules: list[dg.ScheduleDefinition] = [] | ||
|
||
defs = Definitions( | ||
assets=all_assets, | ||
schedules=jobs.schedules, | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
import dagster as dg | ||
|
||
from . import eumetsat_iodc | ||
|
||
|
||
iodc_assets = dg.load_assets_from_modules( | ||
modules=[eumetsat_iodc], | ||
group_name="eumetsat_iodc", | ||
) | ||
|
||
all_assets: list[dg.AssetsDefinition] = [*iodc_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,65 @@ | ||
import datetime as dt | ||
import os | ||
from typing import Any | ||
|
||
import dagster as dg | ||
from dagster_docker import PipesDockerClient | ||
|
||
from constants import LOCATIONS_BY_ENVIRONMENT | ||
|
||
env = os.getenv("ENVIRONMENT", "local") | ||
ZARR_FOLDER = LOCATIONS_BY_ENVIRONMENT[env].SAT_ZARR_FOLDER | ||
|
||
@dg.asset( | ||
name="zarr_archive", | ||
description="".join(( | ||
"Zarr archive of satellite data from EUMETSAT's IODC satellite.", | ||
"Sourced via EUMDAC from EUMETSAT: ", | ||
"https://navigator.eumetsat.int/product/EO:EUM:DAT:MSG:OCA-IODC\n", | ||
"This asset is updated monthly, and surfaced as a Zarr Directory Store ", | ||
"for each month. It is downloaded using the sat container: ", | ||
"https://github.com/openclimatefix/dagster-dags", | ||
)), | ||
key_prefix=["sat", "eumetsat", "iodc"], | ||
metadata={ | ||
"archive_folder": dg.MetadataValue.text(f"{ZARR_FOLDER}/sat/eumetsat/india"), | ||
"area": dg.MetadataValue.text("india"), | ||
"source": dg.MetadataValue.text("eumetsat"), | ||
"expected_runtime": dg.MetadataValue.text("TBD"), | ||
}, | ||
compute_kind="docker", | ||
automation_condition=dg.AutomationCondition.eager(), | ||
tags={ | ||
# "dagster/max_runtime": str(60 * 60 * 10), # Should take 6 ish hours | ||
"dagster/priority": "1", | ||
"dagster/concurrency_key": "eumetsat", | ||
}, | ||
partitions_def=dg.MonthlyPartitionsDefinition( | ||
start_date="2019-01-01", | ||
end_offset=-3, | ||
), | ||
) | ||
def iodc_monthly( | ||
context: dg.AssetExecutionContext, | ||
pipes_docker_client: PipesDockerClient, | ||
) -> Any: | ||
image: str = "ghcr.io/openclimatefix/sat-etl:main" | ||
it: dt.datetime = context.partition_time_window.start | ||
return pipes_docker_client.run( | ||
image=image, | ||
command=[ | ||
"iodc", | ||
"-m", | ||
it.strftime("%Y-%m"), | ||
"--rm", | ||
], | ||
env={ | ||
"EUMETSAT_CONSUMER_KEY": os.environ["EUMETSAT_CONSUMER_KEY"], | ||
"EUMETSAT_CONSUMER_SECRET": os.environ["EUMETSAT_CONSUMER_SECRET"], | ||
}, | ||
container_kwargs={ | ||
"volumes": [f"{ZARR_FOLDER}/sat/eumetsat/india:/mnt/disks/sat"], | ||
}, | ||
context=context, | ||
).get_results() | ||
|
This file was deleted.
Oops, something went wrong.