rslearn 0.0.5__tar.gz → 0.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rslearn-0.0.5/rslearn.egg-info → rslearn-0.0.6}/PKG-INFO +1 -1
- {rslearn-0.0.5 → rslearn-0.0.6}/pyproject.toml +1 -1
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/arg_parser.py +1 -22
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/dataset.py +4 -1
- rslearn-0.0.6/rslearn/template_params.py +26 -0
- {rslearn-0.0.5 → rslearn-0.0.6/rslearn.egg-info}/PKG-INFO +1 -1
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn.egg-info/SOURCES.txt +1 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/LICENSE +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/README.md +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/config/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/config/dataset.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/const.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/aws_landsat.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/aws_open_data.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/aws_sentinel1.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/climate_data_store.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/copernicus.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/data_source.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/earthdaily.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/earthdata_srtm.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/eurocrops.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/gcp_public_data.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/geotiff.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/google_earth_engine.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/local_files.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/openstreetmap.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/planet.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/planet_basemap.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/planetary_computer.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/raster_source.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/usda_cdl.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/usgs_landsat.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/utils.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/vector_source.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/worldcereal.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/worldcover.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/worldpop.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/data_sources/xyz_tiles.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/add_windows.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/index.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/manage.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/materialize.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/remap.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/dataset/window.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/log_utils.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/main.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/clip.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/conv.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/aurora/area.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/aurora/fourier.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/dynamic_hypernetwork.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/flexivit/patch_embed.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/flexivit/utils.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/model_vit.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/copernicusfm_src/util/pos_embed.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/croma.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/box_ops.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/detr.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/matcher.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/position_encoding.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/transformer.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/detr/util.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/faster_rcnn.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/fpn.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/module_wrapper.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/molmo.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/multitask.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/panopticon.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/pick_features.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/pooling_decoder.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/presto/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/presto/presto.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/presto/single_file_presto.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/registry.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/sam2_enc.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/satlaspretrain.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/simple_time_series.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/singletask.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/ssl4eo_s12.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/swin.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/task_embedding.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/terramind.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/trunk.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/unet.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/upsample.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/models/use_croma.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/py.typed +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/tile_stores/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/tile_stores/default.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/tile_stores/tile_store.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/callbacks/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/callbacks/adapters.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/callbacks/freeze_unfreeze.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/callbacks/gradients.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/callbacks/peft.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/data_module.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/dataset.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/lightning_module.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/optimizer.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/prediction_writer.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/scheduler.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/classification.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/detection.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/multi_task.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/per_pixel_regression.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/regression.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/segmentation.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/tasks/task.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/concatenate.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/crop.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/flip.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/mask.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/normalize.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/pad.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/train/transforms/transform.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/__init__.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/array.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/feature.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/fsspec.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/geometry.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/get_utm_ups_crs.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/grid_index.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/jsonargparse.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/mp.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/raster_format.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/rtree_index.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/spatial_index.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/sqlite_index.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/time.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn/utils/vector_format.py +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn.egg-info/dependency_links.txt +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn.egg-info/entry_points.txt +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn.egg-info/requires.txt +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/rslearn.egg-info/top_level.txt +0 -0
- {rslearn-0.0.5 → rslearn-0.0.6}/setup.cfg +0 -0
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
"""Custom Lightning ArgumentParser with environment variable substitution support."""
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
|
-
import re
|
|
5
4
|
from typing import Any
|
|
6
5
|
|
|
7
6
|
from jsonargparse import Namespace
|
|
8
7
|
from lightning.pytorch.cli import LightningArgumentParser
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
def substitute_env_vars_in_string(content: str) -> str:
|
|
12
|
-
"""Substitute environment variables in a string.
|
|
13
|
-
|
|
14
|
-
Replaces ${VAR_NAME} patterns with os.getenv(VAR_NAME, "") values.
|
|
15
|
-
This works on raw string content before YAML parsing.
|
|
16
|
-
|
|
17
|
-
Args:
|
|
18
|
-
content: The string content containing template variables
|
|
19
|
-
|
|
20
|
-
Returns:
|
|
21
|
-
The string with environment variables substituted
|
|
22
|
-
"""
|
|
23
|
-
pattern = r"\$\{([^}]+)\}"
|
|
24
|
-
|
|
25
|
-
def replace_variable(match_obj: re.Match[str]) -> str:
|
|
26
|
-
var_name = match_obj.group(1)
|
|
27
|
-
env_value = os.getenv(var_name, "")
|
|
28
|
-
return env_value if env_value is not None else ""
|
|
29
|
-
|
|
30
|
-
return re.sub(pattern, replace_variable, content)
|
|
9
|
+
from rslearn.template_params import substitute_env_vars_in_string
|
|
31
10
|
|
|
32
11
|
|
|
33
12
|
class RslearnArgumentParser(LightningArgumentParser):
|
|
@@ -8,6 +8,7 @@ from upath import UPath
|
|
|
8
8
|
|
|
9
9
|
from rslearn.config import load_layer_config
|
|
10
10
|
from rslearn.log_utils import get_logger
|
|
11
|
+
from rslearn.template_params import substitute_env_vars_in_string
|
|
11
12
|
from rslearn.tile_stores import TileStore, load_tile_store
|
|
12
13
|
|
|
13
14
|
from .index import DatasetIndex
|
|
@@ -52,7 +53,9 @@ class Dataset:
|
|
|
52
53
|
|
|
53
54
|
# Load dataset configuration.
|
|
54
55
|
with (self.path / "config.json").open("r") as f:
|
|
55
|
-
|
|
56
|
+
config_content = f.read()
|
|
57
|
+
config_content = substitute_env_vars_in_string(config_content)
|
|
58
|
+
config = json.loads(config_content)
|
|
56
59
|
self.layers = {}
|
|
57
60
|
for layer_name, d in config["layers"].items():
|
|
58
61
|
# Layer names must not contain period, since we use period to
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Template parameter substitution utilities for rslearn configuration files."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import re
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def substitute_env_vars_in_string(content: str) -> str:
|
|
8
|
+
"""Substitute environment variables in a string.
|
|
9
|
+
|
|
10
|
+
Replaces ${VAR_NAME} patterns with os.getenv(VAR_NAME, "") values.
|
|
11
|
+
This works on raw string content before YAML/JSON parsing.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
content: The string content containing template variables
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
The string with environment variables substituted
|
|
18
|
+
"""
|
|
19
|
+
pattern = r"\$\{([^}]+)\}"
|
|
20
|
+
|
|
21
|
+
def replace_variable(match_obj: re.Match[str]) -> str:
|
|
22
|
+
var_name = match_obj.group(1)
|
|
23
|
+
env_value = os.getenv(var_name, "")
|
|
24
|
+
return env_value if env_value is not None else ""
|
|
25
|
+
|
|
26
|
+
return re.sub(pattern, replace_variable, content)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|