PyGeoModel 1.0.5__tar.gz → 1.0.7__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.5 → pygeomodel-1.0.7}/PKG-INFO +3 -3
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/PyGeoModel.egg-info/PKG-INFO +3 -3
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/README.md +2 -2
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/__init__.py +1 -1
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/config.py +14 -6
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/results.py +1 -1
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/setup.py +1 -1
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/tests/test_core_api.py +72 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/LICENSE +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/MANIFEST.in +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/PyGeoModel.egg-info/SOURCES.txt +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/PyGeoModel.egg-info/dependency_links.txt +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/PyGeoModel.egg-info/requires.txt +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/PyGeoModel.egg-info/top_level.txt +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/__init__.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/base.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/constants.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openModel.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openUtils/__init__.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openUtils/exceptions.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openUtils/http_client.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openUtils/mdlUtils.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openUtils/parameterValidator.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/ogmsServer2/openUtils/stateManager.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/client.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/consensus.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/context.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/data/__init__.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/data/computeModel.json +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/data/modelContext.txt +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/modeler.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/models.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/notebook.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/qa.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/pygeomodel/recommendation.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/scripts.py +0 -0
- {pygeomodel-1.0.5 → pygeomodel-1.0.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyGeoModel
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: A Python package for integrating OpenGMS geographic model services.
|
|
5
5
|
Home-page: https://github.com/MpLebron/PyGeoModel
|
|
6
6
|
Author: Peilong Ma
|
|
@@ -91,7 +91,7 @@ result = modeler.invoke(
|
|
|
91
91
|
result.to_json("execution_record.json")
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
OpenGMS execution
|
|
94
|
+
OpenGMS execution uses the bundled public demo token by default. For stable or private use, configure your own OpenGMS token:
|
|
95
95
|
|
|
96
96
|
```bash
|
|
97
97
|
export OGMS_TOKEN="your-token"
|
|
@@ -124,7 +124,7 @@ answer = modeler.ask_model("SWAT_Model", "What input data are required?")
|
|
|
124
124
|
answer.to_json("qa_record.json")
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
The recommendation service automatically builds notebook/data context and calls the configured Dify workflow.
|
|
127
|
+
The recommendation service automatically builds notebook/data context and calls the configured Dify workflow. Q&A uses OpenGMS model metadata and an OpenAI-compatible web-enabled model. PyGeoModel includes public demo credentials for these services so the main notebook workflow can run out of the box. For stable, private, or high-volume use, configure your own credentials with `DIFY_API_KEY`, `OPENAI_API_KEY`, `OPENAI_BASE_URL`, and `OPENAI_MODEL`.
|
|
128
128
|
|
|
129
129
|
## Relation to OpenGMS
|
|
130
130
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyGeoModel
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: A Python package for integrating OpenGMS geographic model services.
|
|
5
5
|
Home-page: https://github.com/MpLebron/PyGeoModel
|
|
6
6
|
Author: Peilong Ma
|
|
@@ -91,7 +91,7 @@ result = modeler.invoke(
|
|
|
91
91
|
result.to_json("execution_record.json")
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
OpenGMS execution
|
|
94
|
+
OpenGMS execution uses the bundled public demo token by default. For stable or private use, configure your own OpenGMS token:
|
|
95
95
|
|
|
96
96
|
```bash
|
|
97
97
|
export OGMS_TOKEN="your-token"
|
|
@@ -124,7 +124,7 @@ answer = modeler.ask_model("SWAT_Model", "What input data are required?")
|
|
|
124
124
|
answer.to_json("qa_record.json")
|
|
125
125
|
```
|
|
126
126
|
|
|
127
|
-
The recommendation service automatically builds notebook/data context and calls the configured Dify workflow.
|
|
127
|
+
The recommendation service automatically builds notebook/data context and calls the configured Dify workflow. Q&A uses OpenGMS model metadata and an OpenAI-compatible web-enabled model. PyGeoModel includes public demo credentials for these services so the main notebook workflow can run out of the box. For stable, private, or high-volume use, configure your own credentials with `DIFY_API_KEY`, `OPENAI_API_KEY`, `OPENAI_BASE_URL`, and `OPENAI_MODEL`.
|
|
128
128
|
|
|
129
129
|
## Relation to OpenGMS
|
|
130
130
|
|
|
@@ -45,7 +45,7 @@ result = modeler.invoke(
|
|
|
45
45
|
result.to_json("execution_record.json")
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
OpenGMS execution
|
|
48
|
+
OpenGMS execution uses the bundled public demo token by default. For stable or private use, configure your own OpenGMS token:
|
|
49
49
|
|
|
50
50
|
```bash
|
|
51
51
|
export OGMS_TOKEN="your-token"
|
|
@@ -78,7 +78,7 @@ answer = modeler.ask_model("SWAT_Model", "What input data are required?")
|
|
|
78
78
|
answer.to_json("qa_record.json")
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
The recommendation service automatically builds notebook/data context and calls the configured Dify workflow.
|
|
81
|
+
The recommendation service automatically builds notebook/data context and calls the configured Dify workflow. Q&A uses OpenGMS model metadata and an OpenAI-compatible web-enabled model. PyGeoModel includes public demo credentials for these services so the main notebook workflow can run out of the box. For stable, private, or high-volume use, configure your own credentials with `DIFY_API_KEY`, `OPENAI_API_KEY`, `OPENAI_BASE_URL`, and `OPENAI_MODEL`.
|
|
82
82
|
|
|
83
83
|
## Relation to OpenGMS
|
|
84
84
|
|
|
@@ -8,6 +8,14 @@ from dataclasses import dataclass
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
|
|
10
10
|
|
|
11
|
+
PUBLIC_DEMO_OGMS_TOKEN = '6U3O1Sy5696I5ryJFaYCYVjcIV7rhd1MKK0QGX9A7zafogi8xTdvejl6ISUP1lEs'
|
|
12
|
+
PUBLIC_DEMO_DIFY_API_KEY = 'app-CuNONc6hSct2ap07nmUgcaw9'
|
|
13
|
+
PUBLIC_DEMO_DIFY_BASE_URL = 'https://api.dify.ai/v1'
|
|
14
|
+
PUBLIC_DEMO_OPENAI_API_KEY = 'sk-4bp5a1DcdLSHCiw1401270055f47424b9eA58cAd587266A3'
|
|
15
|
+
PUBLIC_DEMO_OPENAI_BASE_URL = 'https://aihubmix.com/v1'
|
|
16
|
+
PUBLIC_DEMO_OPENAI_MODEL = 'gpt-5.2-low'
|
|
17
|
+
|
|
18
|
+
|
|
11
19
|
@dataclass(frozen=True)
|
|
12
20
|
class OpenGMSConfig:
|
|
13
21
|
token: str | None = None
|
|
@@ -31,7 +39,7 @@ def get_opengms_config() -> OpenGMSConfig:
|
|
|
31
39
|
local = _load_local_api_keys()
|
|
32
40
|
opengms = local.get("opengms", {})
|
|
33
41
|
return OpenGMSConfig(
|
|
34
|
-
token=os.environ.get("OGMS_TOKEN") or opengms.get("token") or opengms.get("api_key"),
|
|
42
|
+
token=os.environ.get("OGMS_TOKEN") or opengms.get("token") or opengms.get("api_key") or PUBLIC_DEMO_OGMS_TOKEN,
|
|
35
43
|
portal_url=os.environ.get("OGMS_BASE_PORTAL_URL", opengms.get("portal_url", OpenGMSConfig.portal_url)),
|
|
36
44
|
manager_url=os.environ.get("OGMS_BASE_MANAGER_URL", opengms.get("manager_url", OpenGMSConfig.manager_url)),
|
|
37
45
|
data_url=os.environ.get("OGMS_BASE_DATA_URL", opengms.get("data_url", OpenGMSConfig.data_url)),
|
|
@@ -44,11 +52,11 @@ def get_llm_config() -> LLMConfig:
|
|
|
44
52
|
dify = local.get("dify", {})
|
|
45
53
|
consensus = local.get("consensus", {})
|
|
46
54
|
return LLMConfig(
|
|
47
|
-
openai_api_key=
|
|
48
|
-
openai_base_url=
|
|
49
|
-
openai_model=
|
|
50
|
-
dify_api_key=
|
|
51
|
-
dify_base_url=
|
|
55
|
+
openai_api_key=os.environ.get("OPENAI_API_KEY") or openai.get("api_key") or PUBLIC_DEMO_OPENAI_API_KEY,
|
|
56
|
+
openai_base_url=os.environ.get("OPENAI_BASE_URL") or openai.get("base_url") or PUBLIC_DEMO_OPENAI_BASE_URL,
|
|
57
|
+
openai_model=os.environ.get("OPENAI_MODEL") or openai.get("model") or PUBLIC_DEMO_OPENAI_MODEL,
|
|
58
|
+
dify_api_key=os.environ.get("DIFY_API_KEY") or dify.get("api_key") or PUBLIC_DEMO_DIFY_API_KEY,
|
|
59
|
+
dify_base_url=os.environ.get("DIFY_BASE_URL") or dify.get("base_url") or PUBLIC_DEMO_DIFY_BASE_URL,
|
|
52
60
|
consensus_api_key=consensus.get("api_key") or os.environ.get("CONSENSUS_API_KEY"),
|
|
53
61
|
consensus_base_url=consensus.get("base_url") or os.environ.get("CONSENSUS_BASE_URL") or LLMConfig.consensus_base_url,
|
|
54
62
|
)
|
|
@@ -29,7 +29,7 @@ class TaskResult:
|
|
|
29
29
|
params: dict[str, Any] = field(default_factory=dict)
|
|
30
30
|
uploaded_inputs: dict[str, Any] = field(default_factory=dict)
|
|
31
31
|
endpoint: str | None = None
|
|
32
|
-
pygeomodel_version: str = "1.0.
|
|
32
|
+
pygeomodel_version: str = "1.0.7"
|
|
33
33
|
execution_time: float | None = None
|
|
34
34
|
created_at: float = field(default_factory=time.time)
|
|
35
35
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import json
|
|
2
|
+
import os
|
|
2
3
|
import tempfile
|
|
3
4
|
import unittest
|
|
4
5
|
from pathlib import Path
|
|
@@ -297,6 +298,77 @@ class CoreApiTests(unittest.TestCase):
|
|
|
297
298
|
qa_path = qa.to_json(tmpdir / "qa.json")
|
|
298
299
|
self.assertEqual(json.loads(Path(qa_path).read_text())["answer"], "a")
|
|
299
300
|
|
|
301
|
+
def test_opengms_config_uses_public_demo_token_as_fallback(self):
|
|
302
|
+
import pygeomodel.config as config_module
|
|
303
|
+
|
|
304
|
+
original_loader = config_module._load_local_api_keys
|
|
305
|
+
original_env = os.environ.get("OGMS_TOKEN")
|
|
306
|
+
try:
|
|
307
|
+
config_module._load_local_api_keys = lambda: {}
|
|
308
|
+
os.environ.pop("OGMS_TOKEN", None)
|
|
309
|
+
self.assertEqual(
|
|
310
|
+
config_module.get_opengms_config().token,
|
|
311
|
+
config_module.PUBLIC_DEMO_OGMS_TOKEN,
|
|
312
|
+
)
|
|
313
|
+
|
|
314
|
+
config_module._load_local_api_keys = lambda: {"opengms": {"token": "local-token"}}
|
|
315
|
+
self.assertEqual(config_module.get_opengms_config().token, "local-token")
|
|
316
|
+
|
|
317
|
+
os.environ["OGMS_TOKEN"] = "env-token"
|
|
318
|
+
self.assertEqual(config_module.get_opengms_config().token, "env-token")
|
|
319
|
+
finally:
|
|
320
|
+
config_module._load_local_api_keys = original_loader
|
|
321
|
+
if original_env is None:
|
|
322
|
+
os.environ.pop("OGMS_TOKEN", None)
|
|
323
|
+
else:
|
|
324
|
+
os.environ["OGMS_TOKEN"] = original_env
|
|
325
|
+
|
|
326
|
+
def test_llm_config_uses_public_demo_credentials_as_fallback(self):
|
|
327
|
+
import pygeomodel.config as config_module
|
|
328
|
+
|
|
329
|
+
env_keys = ["DIFY_API_KEY", "DIFY_BASE_URL", "OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_MODEL"]
|
|
330
|
+
original_env = {key: os.environ.get(key) for key in env_keys}
|
|
331
|
+
original_loader = config_module._load_local_api_keys
|
|
332
|
+
try:
|
|
333
|
+
config_module._load_local_api_keys = lambda: {}
|
|
334
|
+
for key in env_keys:
|
|
335
|
+
os.environ.pop(key, None)
|
|
336
|
+
|
|
337
|
+
cfg = config_module.get_llm_config()
|
|
338
|
+
self.assertEqual(cfg.dify_api_key, config_module.PUBLIC_DEMO_DIFY_API_KEY)
|
|
339
|
+
self.assertEqual(cfg.dify_base_url, config_module.PUBLIC_DEMO_DIFY_BASE_URL)
|
|
340
|
+
self.assertEqual(cfg.openai_api_key, config_module.PUBLIC_DEMO_OPENAI_API_KEY)
|
|
341
|
+
self.assertEqual(cfg.openai_base_url, config_module.PUBLIC_DEMO_OPENAI_BASE_URL)
|
|
342
|
+
self.assertEqual(cfg.openai_model, config_module.PUBLIC_DEMO_OPENAI_MODEL)
|
|
343
|
+
|
|
344
|
+
config_module._load_local_api_keys = lambda: {
|
|
345
|
+
"dify": {"api_key": "local-dify", "base_url": "https://local-dify.example/v1"},
|
|
346
|
+
"openai": {
|
|
347
|
+
"api_key": "local-openai",
|
|
348
|
+
"base_url": "https://local-openai.example/v1",
|
|
349
|
+
"model": "local-model",
|
|
350
|
+
},
|
|
351
|
+
}
|
|
352
|
+
cfg = config_module.get_llm_config()
|
|
353
|
+
self.assertEqual(cfg.dify_api_key, "local-dify")
|
|
354
|
+
self.assertEqual(cfg.openai_api_key, "local-openai")
|
|
355
|
+
self.assertEqual(cfg.openai_model, "local-model")
|
|
356
|
+
|
|
357
|
+
os.environ["DIFY_API_KEY"] = "env-dify"
|
|
358
|
+
os.environ["OPENAI_API_KEY"] = "env-openai"
|
|
359
|
+
os.environ["OPENAI_MODEL"] = "env-model"
|
|
360
|
+
cfg = config_module.get_llm_config()
|
|
361
|
+
self.assertEqual(cfg.dify_api_key, "env-dify")
|
|
362
|
+
self.assertEqual(cfg.openai_api_key, "env-openai")
|
|
363
|
+
self.assertEqual(cfg.openai_model, "env-model")
|
|
364
|
+
finally:
|
|
365
|
+
config_module._load_local_api_keys = original_loader
|
|
366
|
+
for key, value in original_env.items():
|
|
367
|
+
if value is None:
|
|
368
|
+
os.environ.pop(key, None)
|
|
369
|
+
else:
|
|
370
|
+
os.environ[key] = value
|
|
371
|
+
|
|
300
372
|
def test_recommendation_result_has_notebook_rich_display(self):
|
|
301
373
|
from pygeomodel import RecommendationResult
|
|
302
374
|
|
|
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
|