PyGeoModel 1.0.14__tar.gz → 1.0.15__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.
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/PKG-INFO +1 -1
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/PyGeoModel.egg-info/PKG-INFO +1 -1
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/__init__.py +1 -1
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/modeler.py +20 -3
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/setup.py +1 -1
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/tests/test_core_api.py +36 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/LICENSE +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/MANIFEST.in +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/PyGeoModel.egg-info/SOURCES.txt +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/PyGeoModel.egg-info/dependency_links.txt +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/PyGeoModel.egg-info/requires.txt +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/PyGeoModel.egg-info/top_level.txt +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/README.md +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/__init__.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/base.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/constants.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openModel.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openUtils/__init__.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openUtils/exceptions.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openUtils/http_client.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openUtils/mdlUtils.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openUtils/parameterValidator.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/ogmsServer2/openUtils/stateManager.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/client.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/config.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/consensus.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/context.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/data/__init__.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/data/computeModel.json +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/data/description_translations_en.json +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/data/modelContext.txt +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/data/modellist_2070.csv +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/models.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/notebook.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/qa.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/recommendation.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/pygeomodel/results.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/scripts.py +0 -0
- {pygeomodel-1.0.14 → pygeomodel-1.0.15}/setup.cfg +0 -0
|
@@ -29,6 +29,7 @@ class GeoModeler:
|
|
|
29
29
|
self._uses_custom_data_path = data_path is not None
|
|
30
30
|
self.data_path = self._resolve_data_path(data_path)
|
|
31
31
|
self._models_data = self._load_catalog()
|
|
32
|
+
self._model_aliases = self._build_model_aliases()
|
|
32
33
|
self.model_names = list(self._models_data.keys())
|
|
33
34
|
self.client = client or OpenGMSClient()
|
|
34
35
|
self.last_result: TaskResult | None = None
|
|
@@ -68,9 +69,25 @@ class GeoModeler:
|
|
|
68
69
|
return [summary for _, _, summary in scored[:limit]]
|
|
69
70
|
|
|
70
71
|
def get_model(self, model_name: str) -> ModelService:
|
|
71
|
-
|
|
72
|
+
canonical_name = self._canonical_model_name(model_name)
|
|
73
|
+
return ModelService.from_raw(canonical_name, self._models_data[canonical_name])
|
|
74
|
+
|
|
75
|
+
def _canonical_model_name(self, model_name: str) -> str:
|
|
76
|
+
requested_name = str(model_name or "").strip()
|
|
77
|
+
canonical_name = self._model_aliases.get(requested_name)
|
|
78
|
+
if canonical_name is None:
|
|
72
79
|
raise KeyError(f"Model '{model_name}' was not found in the local OpenGMS catalog")
|
|
73
|
-
return
|
|
80
|
+
return canonical_name
|
|
81
|
+
|
|
82
|
+
def _build_model_aliases(self) -> dict[str, str]:
|
|
83
|
+
aliases: dict[str, str] = {}
|
|
84
|
+
for original_name, raw in self._models_data.items():
|
|
85
|
+
service = ModelService.from_raw(original_name, raw)
|
|
86
|
+
for alias in (original_name, service.display_name):
|
|
87
|
+
clean_alias = str(alias or "").strip()
|
|
88
|
+
if clean_alias:
|
|
89
|
+
aliases.setdefault(clean_alias, original_name)
|
|
90
|
+
return aliases
|
|
74
91
|
|
|
75
92
|
def invoke(
|
|
76
93
|
self,
|
|
@@ -83,7 +100,7 @@ class GeoModeler:
|
|
|
83
100
|
model = self.get_model(model_name)
|
|
84
101
|
normalized_params = model.normalize_params(params)
|
|
85
102
|
started = time.time()
|
|
86
|
-
response = self.client.create_task(
|
|
103
|
+
response = self.client.create_task(model.name, normalized_params, wait=wait)
|
|
87
104
|
result = TaskResult(
|
|
88
105
|
model_name=model.name,
|
|
89
106
|
model_id=model.model_id,
|
|
@@ -124,6 +124,42 @@ class CoreApiTests(unittest.TestCase):
|
|
|
124
124
|
self.assertEqual(model.display_name, "BES Land Surface Temperature Algorithm")
|
|
125
125
|
self.assertEqual(model.inputs[0].description, "Satellite Brightness of Channel 4")
|
|
126
126
|
|
|
127
|
+
def test_english_display_name_resolves_to_original_opengms_name(self):
|
|
128
|
+
from pygeomodel import GeoModeler
|
|
129
|
+
|
|
130
|
+
with tempfile.TemporaryDirectory() as tmpdir:
|
|
131
|
+
tmp_path = Path(tmpdir)
|
|
132
|
+
catalog_path = tmp_path / "computeModel.json"
|
|
133
|
+
registry_path = tmp_path / "modellist_2070.csv"
|
|
134
|
+
catalog_path.write_text(
|
|
135
|
+
json.dumps(
|
|
136
|
+
{
|
|
137
|
+
"中文模型": {
|
|
138
|
+
"md5": "md5-demo",
|
|
139
|
+
"_id": "uid-demo",
|
|
140
|
+
"description": "Demo model",
|
|
141
|
+
"mdlJson": {"mdl": {"states": []}},
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
),
|
|
145
|
+
encoding="utf-8",
|
|
146
|
+
)
|
|
147
|
+
registry_path.write_text(
|
|
148
|
+
"\ufeff序号,MD5,名称,介绍,模型UID,模型参数及说明,是否有示例数据(资源),display_name_en\n"
|
|
149
|
+
"1,md5-demo,中文模型,,uid-demo,,,English Demo Model\n",
|
|
150
|
+
encoding="utf-8",
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
client = FakeClient()
|
|
154
|
+
modeler = GeoModeler(data_path=catalog_path, client=client)
|
|
155
|
+
model = modeler.get_model("English Demo Model")
|
|
156
|
+
result = modeler.invoke("English Demo Model", params={})
|
|
157
|
+
|
|
158
|
+
self.assertEqual(model.name, "中文模型")
|
|
159
|
+
self.assertEqual(model.display_name, "English Demo Model")
|
|
160
|
+
self.assertEqual(result.model_name, "中文模型")
|
|
161
|
+
self.assertEqual(client.calls[0][0], "中文模型")
|
|
162
|
+
|
|
127
163
|
def test_search_and_get_model_parse_metadata(self):
|
|
128
164
|
from pygeomodel import GeoModeler, ModelService
|
|
129
165
|
|
|
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
|