psr-factory 5.0.0b16__py3-none-win_amd64.whl → 5.0.0b67__py3-none-win_amd64.whl
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.
- psr/execqueue/client.py +35 -14
- psr/execqueue/config.py +8 -0
- psr/execqueue/db.py +77 -11
- psr/execqueue/server.py +363 -57
- psr/execqueue/watcher.py +25 -11
- psr/factory/__init__.py +1 -1
- psr/factory/api.py +814 -523
- psr/factory/factory.dll +0 -0
- psr/factory/factory.pmd +120 -51
- psr/factory/factory.pmk +3028 -2199
- psr/factory/factorylib.py +32 -2
- psr/factory/samples/sddp_case01.py +3 -2
- psr/factory/samples/sddp_case21.py +3 -3
- psr/{cloud/version.py → outputs/__init__.py} +2 -2
- psr/outputs/outputs.py +179 -0
- psr/outputs/resample.py +289 -0
- psr/psrfcommon/psrfcommon.py +4 -1
- psr/runner/runner.py +74 -23
- psr_factory-5.0.0b67.dist-info/METADATA +47 -0
- psr_factory-5.0.0b67.dist-info/RECORD +32 -0
- psr/cloud/__init__.py +0 -7
- psr/cloud/aws.py +0 -256
- psr/cloud/cloud.py +0 -1444
- psr/cloud/data.py +0 -127
- psr/cloud/desktop.py +0 -82
- psr/cloud/log.py +0 -40
- psr/cloud/status.py +0 -81
- psr/cloud/tempfile.py +0 -117
- psr/cloud/xml.py +0 -57
- psr/factory/libcurl-x64.dll +0 -0
- psr_factory-5.0.0b16.dist-info/METADATA +0 -123
- psr_factory-5.0.0b16.dist-info/RECORD +0 -40
- {psr_factory-5.0.0b16.dist-info → psr_factory-5.0.0b67.dist-info}/WHEEL +0 -0
- {psr_factory-5.0.0b16.dist-info → psr_factory-5.0.0b67.dist-info}/licenses/LICENSE.txt +0 -0
- {psr_factory-5.0.0b16.dist-info → psr_factory-5.0.0b67.dist-info}/top_level.txt +0 -0
psr/execqueue/watcher.py
CHANGED
|
@@ -12,7 +12,7 @@ SERVER_URL = os.getenv("SERVER_URL", "http://127.0.0.1:5000")
|
|
|
12
12
|
WATCH_DIR = os.getenv("WATCH_DIR")
|
|
13
13
|
PROCESSED_DIR = os.getenv("PROCESSED_DIR")
|
|
14
14
|
RESULTS_DIR = os.getenv("RESULTS_DIR", "results")
|
|
15
|
-
SLEEP_SECONDS = int(os.getenv("WATCHER_SLEEP", "
|
|
15
|
+
SLEEP_SECONDS = int(os.getenv("WATCHER_SLEEP", "10"))
|
|
16
16
|
DB_PATH = os.getenv("WATCHER_DB_PATH", "watcher.sqlite")
|
|
17
17
|
|
|
18
18
|
|
|
@@ -42,11 +42,28 @@ def _log_to_db(filename, cloud_upload_id):
|
|
|
42
42
|
conn.commit()
|
|
43
43
|
conn.close()
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
def _is_file_locked(filepath):
|
|
46
|
+
"""Returns True if the file is locked by another process (e.g., still being copied)."""
|
|
47
|
+
if not os.path.exists(filepath):
|
|
48
|
+
return True
|
|
49
|
+
try:
|
|
50
|
+
# Try to open for exclusive writing
|
|
51
|
+
with open(filepath, 'rb+') as f:
|
|
52
|
+
pass
|
|
53
|
+
return False
|
|
54
|
+
except (OSError, PermissionError):
|
|
55
|
+
return True
|
|
56
|
+
|
|
46
57
|
def _process_zip_files():
|
|
47
58
|
for filename in os.listdir(WATCH_DIR):
|
|
48
59
|
if filename.lower().endswith('.zip'):
|
|
49
60
|
zip_path = os.path.join(WATCH_DIR, filename)
|
|
61
|
+
|
|
62
|
+
# Check if the file is locked
|
|
63
|
+
if _is_file_locked(zip_path):
|
|
64
|
+
logging.info(f"Skipping {zip_path}: file is locked or being copied.")
|
|
65
|
+
continue
|
|
66
|
+
|
|
50
67
|
logging.info(f"zip file found: {zip_path}")
|
|
51
68
|
|
|
52
69
|
case_id = execqueue.upload_case_file(zip_path, SERVER_URL)
|
|
@@ -73,11 +90,12 @@ def _check_and_download_results():
|
|
|
73
90
|
rows = cursor.fetchall()
|
|
74
91
|
for row in rows:
|
|
75
92
|
record_id, filename, cloud_upload_id = row
|
|
76
|
-
|
|
77
|
-
status
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
status_id, status_msg = execqueue.get_execution_status(cloud_upload_id, SERVER_URL, cloud_execution=True)
|
|
94
|
+
logging.info(f"Execution status for {cloud_upload_id}: {status_id} - {status_msg}")
|
|
95
|
+
if status_id is None:
|
|
96
|
+
logging.error(f"Failed to get status for {cloud_upload_id}. Skipping download.")
|
|
97
|
+
continue
|
|
98
|
+
if status_id == 5 or status_id == 6:
|
|
81
99
|
files = execqueue.get_results(cloud_upload_id, SERVER_URL, cloud_execution=True)
|
|
82
100
|
if files:
|
|
83
101
|
base_filename = os.path.splitext(filename)[0]
|
|
@@ -91,10 +109,6 @@ def _check_and_download_results():
|
|
|
91
109
|
cursor.execute("UPDATE processed_files SET downloaded=1 WHERE id=?", (record_id,))
|
|
92
110
|
conn.commit()
|
|
93
111
|
logging.info(f"Results of {cloud_upload_id} downloaded to {download_path}")
|
|
94
|
-
elif status == "4" or status == 4:
|
|
95
|
-
logging.info(f"Execution {cloud_upload_id} is finished with errors.")
|
|
96
|
-
cursor.execute("UPDATE processed_files SET downloaded=4 WHERE id=?", (record_id,))
|
|
97
|
-
conn.commit()
|
|
98
112
|
|
|
99
113
|
conn.close()
|
|
100
114
|
|