|
1 | 1 | import os
|
| 2 | +from pathlib import Path |
2 | 3 |
|
3 | 4 | from bag3d.common.resources.executables import (
|
4 | 5 | GDALResource,
|
|
12 | 13 | from bag3d.common.resources.database import DatabaseResource
|
13 | 14 | from bag3d.common.resources.version import VersionResource
|
14 | 15 |
|
15 |
| -from dagster import EnvVar |
| 16 | +from dagster import EnvVar, get_dagster_logger |
16 | 17 |
|
17 |
| -# The 'mount_point' is the directory in the container that is bind-mounted on the host |
| 18 | +logger = get_dagster_logger() |
18 | 19 |
|
19 | 20 | version = VersionResource(os.getenv("BAG3D_RELEASE_VERSION"))
|
20 | 21 |
|
21 | 22 |
|
22 |
| -gdal_local = GDALResource( |
| 23 | +gdal = GDALResource( |
23 | 24 | exe_ogr2ogr=os.getenv("EXE_PATH_OGR2OGR"),
|
24 | 25 | exe_ogrinfo=os.getenv("EXE_PATH_OGRINFO"),
|
25 | 26 | exe_sozip=os.getenv("EXE_PATH_SOZIP"),
|
26 | 27 | )
|
27 | 28 |
|
28 | 29 |
|
29 |
| -pdal_local = PDALResource(exe_pdal=os.getenv("EXE_PATH_PDAL")) |
| 30 | +pdal = PDALResource(exe_pdal=os.getenv("EXE_PATH_PDAL")) |
30 | 31 |
|
31 | 32 |
|
32 | 33 | db_connection = DatabaseResource(
|
|
47 | 48 | dir_id=os.getenv("BAG3D_RELEASE_VERSION"),
|
48 | 49 | )
|
49 | 50 |
|
| 51 | +file_store_test = FileStoreResource( |
| 52 | + data_dir=str(Path(os.getenv("BAG3D_FILESTORE")) / "reconstruction_input"), |
| 53 | + dir_id=os.getenv("BAG3D_RELEASE_VERSION"), |
| 54 | +) |
| 55 | +file_store_fastssd_test = FileStoreResource( |
| 56 | + data_dir=str(Path(os.getenv("BAG3D_FILESTORE")) / "integration_core"), |
| 57 | + dir_id=os.getenv("BAG3D_RELEASE_VERSION"), |
| 58 | +) |
50 | 59 |
|
51 | 60 | # Configure for gilfoyle
|
52 | 61 | file_store_gilfoyle = FileStoreResource(data_dir="/data")
|
|
74 | 83 |
|
75 | 84 |
|
76 | 85 | RESOURCES_LOCAL = {
|
77 |
| - "gdal": gdal_local, |
| 86 | + "gdal": gdal, |
78 | 87 | "file_store": file_store,
|
79 | 88 | "file_store_fastssd": file_store_fastssd,
|
80 | 89 | "db_connection": db_connection,
|
81 |
| - "pdal": pdal_local, |
| 90 | + "pdal": pdal, |
82 | 91 | "lastools": lastools,
|
83 | 92 | "tyler": tyler,
|
84 | 93 | "geoflow": geoflow,
|
|
87 | 96 | }
|
88 | 97 |
|
89 | 98 |
|
90 |
| -RESOURCES_PYTEST = { |
91 |
| - "gdal": gdal_local, |
92 |
| - "file_store": file_store, |
93 |
| - "file_store_fastssd": file_store_fastssd, |
| 99 | +RESOURCES_TEST = { |
| 100 | + "gdal": gdal, |
| 101 | + "file_store": file_store_test, |
| 102 | + "file_store_fastssd": file_store_fastssd_test, |
94 | 103 | "db_connection": db_connection,
|
95 |
| - "pdal": pdal_local, |
| 104 | + "pdal": pdal, |
96 | 105 | "lastools": lastools,
|
97 | 106 | "tyler": tyler,
|
98 | 107 | "geoflow": geoflow,
|
|
101 | 110 | }
|
102 | 111 |
|
103 | 112 | RESOURCES_PROD = {
|
104 |
| - "gdal": gdal_local, |
| 113 | + "gdal": gdal, |
105 | 114 | "file_store": file_store_gilfoyle,
|
106 | 115 | "file_store_fastssd": file_store_gilfoyle_fastssd,
|
107 | 116 | "db_connection": db_connection,
|
108 |
| - "pdal": pdal_local, |
| 117 | + "pdal": pdal, |
109 | 118 | "lastools": lastools,
|
110 | 119 | "tyler": tyler,
|
111 | 120 | "geoflow": geoflow,
|
112 | 121 | "roofer": roofer,
|
113 | 122 | "version": version,
|
114 | 123 | }
|
115 | 124 |
|
116 |
| -# Resource definitions for import |
| 125 | +RESOURCES_DEFAULT = { |
| 126 | + "gdal": GDALResource(), |
| 127 | + "file_store": FileStoreResource(), |
| 128 | + "file_store_fastssd": FileStoreResource(), |
| 129 | + "db_connection": DatabaseResource(), |
| 130 | + "pdal": PDALResource(), |
| 131 | + "lastools": LASToolsResource(), |
| 132 | + "tyler": TylerResource(), |
| 133 | + "geoflow": GeoflowResource(), |
| 134 | + "roofer": RooferResource(), |
| 135 | + "version": VersionResource(), |
| 136 | +} |
| 137 | + |
117 | 138 |
|
118 |
| -resource_defs_by_deployment_name = { |
| 139 | +resource_defs_by_env_name = { |
119 | 140 | "prod": RESOURCES_PROD,
|
120 | 141 | "local": RESOURCES_LOCAL,
|
121 |
| - "pytest": RESOURCES_PYTEST, |
| 142 | + "test": RESOURCES_TEST, |
| 143 | + "default": RESOURCES_DEFAULT, |
122 | 144 | }
|
123 |
| -deployment_name = os.environ.get("DAGSTER_DEPLOYMENT", "local") |
124 |
| -resource_defs = resource_defs_by_deployment_name[deployment_name] |
| 145 | +env_name = os.getenv("DAGSTER_ENVIRONMENT", "default").lower() |
| 146 | +if env_name not in resource_defs_by_env_name.keys(): |
| 147 | + logger.warning(f"Invalid environment: {env_name}, setting to default") |
| 148 | + env_name = "default" |
| 149 | + |
| 150 | +resource_defs = resource_defs_by_env_name[env_name] |
0 commit comments