Skip to content

Commit

Permalink
fix(repo): Use just one code location
Browse files Browse the repository at this point in the history
  • Loading branch information
devsjc committed Jan 20, 2025
1 parent b932a81 commit 2304c2f
Show file tree
Hide file tree
Showing 26 changed files with 66 additions and 62 deletions.
5 changes: 2 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ COPY pyproject.toml /opt/dagster/app
# DagsterInstance.
RUN uv sync

# Set the code location module to be loaded by the gRPC server
ENV MODULE_NAME=local_archives
EXPOSE 4000

# Using CMD rather than RUN allows the command to be overridden in
# run launchers or executors to run other commands using this image.
# This is important as runs are executed inside this container.
ENTRYPOINT ["uv", "run"]
CMD ["dagster", "api", "grpc", "-h", "0.0.0.0", "-p", "4000", "-m", "local_archives"]
CMD ["dagster", "api", "grpc", "-h", "0.0.0.0", "-p", "4000", "-m", "dagster_dags"]

12 changes: 4 additions & 8 deletions infrastructure/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ services:
PGDATA: "/var/lib/postgresql/data"
volumes:
- dagster-pgdata-vol:/var/lib/postgresql/data
expose:
- "5432" # Publishes on network but not to host
networks: ["dagster-network"]
healthcheck:
test: pg_isready -U $$POSTGRES_USER -d $$POSTGRES_DB
Expand All @@ -37,16 +35,14 @@ services:
# This service runs the gRPC server that loads user code, used by both dagster-webserver
# and dagster-daemon. By setting DAGSTER_CURRENT_IMAGE to its own image, we tell the
# run launcher to use this same image when launching runs in a new container as well.
dagster-codeserver_local-archives:
container_name: dagster-codeserver_local-archives
dagster-codeserver:
container_name: dagster-codeserver
image: ghcr.io/openclimatefix/dagster-dags:devsjc-code-container
restart: always
environment:
<<: *postgres-variables
DAGSTER_CURRENT_IMAGE: "ghcr.io/openclimatefix/dagster-dags"
DAGSTER_HOME: "/opt/dagster/home"
expose:
- "4000"
configs: *dagster-configs
networks: ["dagster-network"]

Expand Down Expand Up @@ -111,9 +107,9 @@ configs:
content: |
load_from:
- grpc_server:
host: "dagster-codeserver_local-archives"
host: "dagster-codeserver"
port: 4000
location_name: "local_archives"
location_name: "dagster_dags"
dagster.yaml:
content: |
Expand Down
17 changes: 0 additions & 17 deletions src/cloud_archives/__init__.py

This file was deleted.

4 changes: 4 additions & 0 deletions src/dagster_dags/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from .definitions import defs

__all__ = ['defs']

File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions src/dagster_dags/definitions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import dagster as dg

Check failure on line 1 in src/dagster_dags/definitions.py

View workflow job for this annotation

GitHub Actions / lint-typecheck

Ruff (D100)

src/dagster_dags/definitions.py:1:1: D100 Missing docstring in public module
from dagster_docker import PipesDockerClient

from . import nwp, pv, sat


class BaseStorageResource(dg.ConfigurableResource):
"""A resource defining where to store external data.
Consists of a location on disk accessible to the Dagster instance.
Where possible all data not handled by Dagster's IO managers (e.g.
data downloaded via dagster pipes docker instances) will use this
path as a base location.
"""

location: str

nwp_assets = dg.load_assets_from_package_module(
package_module=nwp,
group_name="nwp",
key_prefix="nwp",
)

sat_assets = dg.load_assets_from_package_module(
package_module=sat,
group_name="sat",
key_prefix="sat",
)

pv_assets = dg.load_assets_from_package_module(
package_module=pv,
group_name="pv",
key_prefix="pv",
)

defs = dg.Definitions(
assets=[*nwp_assets, *sat_assets, *pv_assets],
resources={
"pipes_subprocess_client": dg.PipesSubprocessClient(),
"pipes_docker_client": PipesDockerClient(),
"base_storage_resource": BaseStorageResource(
location=dg.EnvVar("BASE_STORAGE_PATH"),
),
},
jobs=[],
schedules=[],
)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions src/local_archives/__init__.py

This file was deleted.

1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Empty file removed tests/cloud_archives/__init__.py
Empty file.
11 changes: 6 additions & 5 deletions tests/compile_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import dagster as dg

from src.local_archives import nwp_assets, sat_assets
from src.dagster_dags import defs


class TestAssetKeyPrefixes(unittest.TestCase):
def test_nwp_asset_key_prefixes(self) -> None:
"""Test asset keys for all nwp assets have the correct key structure."""
for asset in [*nwp_assets, *sat_assets]:
if isinstance(asset, dg.AssetsDefinition):
# Ensure that the prefix is one of the expected flavours
self.assertIn( asset.key.path[0], ["nwp", "sat", "air"])
if defs.assets is not None:
for asset in defs.assets:
if isinstance(asset, dg.AssetsDefinition):
# Ensure that the prefix is one of the expected flavours
self.assertIn( asset.key.path[0], ["nwp", "sat", "air", "pv"])

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from datetime import UTC, datetime

from src.cloud_archives.pv.passiv.passiv_monthly import get_monthly_passiv_data
from src.dagster_dags.pv.passiv.passiv_monthly import get_monthly_passiv_data


@unittest.skip("rawdata endpoint not on new URL")
Expand Down

0 comments on commit 2304c2f

Please sign in to comment.