tlpytools 0.2.6__tar.gz → 0.2.8__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.
Files changed (60) hide show
  1. {tlpytools-0.2.6 → tlpytools-0.2.8}/.env.example +4 -1
  2. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/copilot-instructions.md +2 -2
  3. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/workflows/deploy.yml +1 -1
  4. {tlpytools-0.2.6 → tlpytools-0.2.8}/CHANGELOG.md +23 -0
  5. {tlpytools-0.2.6 → tlpytools-0.2.8}/DEVELOPER_GUIDE.md +2 -2
  6. {tlpytools-0.2.6 → tlpytools-0.2.8}/ENVIRONMENT_VARIABLES.md +12 -0
  7. {tlpytools-0.2.6 → tlpytools-0.2.8}/PKG-INFO +2 -2
  8. {tlpytools-0.2.6 → tlpytools-0.2.8}/pyproject.toml +1 -1
  9. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/__init__.py +1 -1
  10. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/adls_server.py +69 -17
  11. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/batch_task_runner.py +5 -2
  12. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/orchestrator.py +93 -37
  13. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/test_orca_unit.py +9 -4
  14. {tlpytools-0.2.6 → tlpytools-0.2.8}/uv.lock +214 -213
  15. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/skills/README.md +0 -0
  16. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/skills/prepare-official-release/SKILL.md +0 -0
  17. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/workflows/code-formatting-pr.yml +0 -0
  18. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/workflows/code-formatting.yml +0 -0
  19. {tlpytools-0.2.6 → tlpytools-0.2.8}/.github/workflows/test.yml +0 -0
  20. {tlpytools-0.2.6 → tlpytools-0.2.8}/.gitignore +0 -0
  21. {tlpytools-0.2.6 → tlpytools-0.2.8}/.pre-commit-config.yaml +0 -0
  22. {tlpytools-0.2.6 → tlpytools-0.2.8}/.python-version +0 -0
  23. {tlpytools-0.2.6 → tlpytools-0.2.8}/Makefile +0 -0
  24. {tlpytools-0.2.6 → tlpytools-0.2.8}/README.md +0 -0
  25. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/adls_server.md +0 -0
  26. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/azure_credential_manager.md +0 -0
  27. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/diagrams/README.md +0 -0
  28. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/diagrams/orca_cloud_workflow.drawio +0 -0
  29. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/diagrams/orca_detailed_steps.drawio +0 -0
  30. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/diagrams/orca_file_structure.drawio +0 -0
  31. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/diagrams/orca_local_workflow.drawio +0 -0
  32. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/diagrams/orca_main_features.drawio +0 -0
  33. {tlpytools-0.2.6 → tlpytools-0.2.8}/docs/unified_logging.md +0 -0
  34. {tlpytools-0.2.6 → tlpytools-0.2.8}/requirements.txt +0 -0
  35. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/examples/batchtask.py +0 -0
  36. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/examples/data_files/example.csv +0 -0
  37. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/examples/mydataproject.py +0 -0
  38. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/examples/readwritedata.py +0 -0
  39. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/examples/unified_logging.py +0 -0
  40. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/azure_credential.py +0 -0
  41. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/config.py +0 -0
  42. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/data.py +0 -0
  43. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/data_store.py +0 -0
  44. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/env_config.py +0 -0
  45. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/log.py +0 -0
  46. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/README.md +0 -0
  47. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/__init__.py +0 -0
  48. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/__main__.py +0 -0
  49. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/cli.py +0 -0
  50. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/orca_model_config_barebone.yaml +0 -0
  51. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/orca/orca_model_config_example.yaml +0 -0
  52. {tlpytools-0.2.6 → tlpytools-0.2.8}/src/tlpytools/sql_server.py +0 -0
  53. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/README.md +0 -0
  54. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/__init__.py +0 -0
  55. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/conftest.py +0 -0
  56. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/run_tests.py +0 -0
  57. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/test_azure_credential.py +0 -0
  58. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/test_basic.py +0 -0
  59. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/test_core.py +0 -0
  60. {tlpytools-0.2.6 → tlpytools-0.2.8}/tests/test_orca_integration.py +0 -0
@@ -14,9 +14,12 @@ AZURE_SUBSCRIPTION_ID=your-subscription-id
14
14
  AZURE_RESOURCE_GROUP=your-resource-group
15
15
  MANAGED_IDENTITY_NAME=your-managed-identity
16
16
 
17
+ # Optional Environment Variables for Azure Batch (Do not set these unless for testing different VM set up for Batch)
18
+ # AZ_BATCH_NODE_CUSTOM_MOUNT=$AZ_BATCH_NODE_MOUNTS_DIR/datadisk
19
+
17
20
  # Azure Data Lake Storage
18
21
  ORCA_ADLS_URL=yourstorageaccount.dfs.core.windows.net
19
- ORCA_ADLS_CONTAINER=yourcontainer
22
+ ORCA_ADLS_CONTAINER_PATH=yourcontainer/sub/path
20
23
 
21
24
  # Azure SQL Server URI
22
25
  TLPT_AZURE_SQL_URI=yoursever.database.windows.net
@@ -98,8 +98,8 @@ Interpretation for agent PRs:
98
98
 
99
99
  Observed result:
100
100
  - Build succeeds and produces:
101
- - `dist/tlpytools-0.2.6.tar.gz`
102
- - `dist/tlpytools-0.2.6-py3-none-any.whl`
101
+ - `dist/tlpytools-0.2.8.tar.gz`
102
+ - `dist/tlpytools-0.2.8-py3-none-any.whl`
103
103
 
104
104
  ### 5) Run
105
105
  - ORCA CLI (module form):
@@ -4,7 +4,7 @@ on:
4
4
  workflow_dispatch:
5
5
  inputs:
6
6
  version:
7
- description: 'Version number to release (e.g., 0.2.6)'
7
+ description: 'Version number to release (e.g., 0.2.8)'
8
8
  required: true
9
9
  type: string
10
10
  prerelease:
@@ -2,6 +2,29 @@
2
2
 
3
3
  All notable changes to TLPyTools will be documented in this file.
4
4
 
5
+ ## [0.2.8]
6
+
7
+ ### Changed
8
+ - **Renamed `ORCA_ADLS_CONTAINER` to `ORCA_ADLS_CONTAINER_PATH`:**
9
+ - Variable now accepts either a bare container name (`mycontainer`) or a container with a sub-path (`mycontainer/projects/v2`)
10
+ - The first path segment is used as the ADLS filesystem (container) name; any remaining segments are prepended to the project folder path
11
+ - **Breaking Change**: Users must rename `ORCA_ADLS_CONTAINER` to `ORCA_ADLS_CONTAINER_PATH` in their `.env` files
12
+ - **Configurable Azure Batch node mount path via `AZ_BATCH_NODE_CUSTOM_MOUNT`:**
13
+ - Replaces the hardcoded `$AZ_BATCH_NODE_MOUNTS_DIR/datadisk` volume mount in `BatchTaskRunner`
14
+ - Default: `$AZ_BATCH_NODE_MOUNTS_DIR/datadisk` (virtual file system mount on the Azure Batch VM node)
15
+ - Override to use task working directory, e.g. `$AZ_BATCH_TASK_WORKING_DIR`
16
+ - See [Azure Batch: Files and directories](https://learn.microsoft.com/en-us/azure/batch/files-and-directories) for available node environment variables
17
+
18
+ ### Fixed
19
+ - **`InvalidQueryParameterValue` error when `ORCA_ADLS_CONTAINER_PATH` contains a sub-path:**
20
+ - The ADLS SDK requires the filesystem (container) name to be a single path component with no slashes
21
+ - `_get_adls_config` now splits the value on the first `/` and prepends any sub-path to `adls_folder`
22
+
23
+ ## [0.2.7]
24
+
25
+ ### Fixed
26
+ * Set environment variable PYTHONHASHSEED to 0 before starting subprocess calls of sub modules
27
+
5
28
  ## [0.2.6]
6
29
 
7
30
  ### Fixed
@@ -200,7 +200,7 @@ make check-all
200
200
  4. Click **"Run workflow"** button
201
201
  5. Fill in the required information:
202
202
  - **Branch**: Select `main` (or your release branch)
203
- - **Version number**: Enter the new version (e.g., `0.2.6`)
203
+ - **Version number**: Enter the new version (e.g., `0.2.8`)
204
204
  - **Is this a pre-release?**: Check if this is a pre-release version
205
205
 
206
206
  #### 3. Monitor the Release
@@ -219,7 +219,7 @@ After the workflow completes:
219
219
 
220
220
  ```bash
221
221
  # Verify the package is available on PyPI
222
- pip install tlpytools==0.2.6 # Replace with your version
222
+ pip install tlpytools==0.2.8 # Replace with your version
223
223
 
224
224
  # Test installation in a fresh environment
225
225
  python -c "import tlpytools; print(tlpytools.__version__)"
@@ -53,6 +53,14 @@ nano .env # Linux/macOS
53
53
  - Note: The https:// prefix is automatically added by the application
54
54
  - **Breaking Change**: Previously used "yourstorageaccount.dfs.core.windows.net" as default
55
55
 
56
+ - `ORCA_ADLS_CONTAINER_PATH`: ADLS container name, optionally followed by a sub-path to scope all operations under a specific directory within that container.
57
+ - Format: `{container}` or `{container}/{sub/path}`
58
+ - Example (container only): `mycontainer`
59
+ - Example (container + sub-path): `mycontainer/projects/v2`
60
+ - Used by: orchestrator.py
61
+ - **Strictly Required**: Application will fail with ValueError if not set
62
+ - Note: The first path segment is used as the ADLS filesystem (container) name; any remaining segments are prepended to the project folder path.
63
+
56
64
  ### Azure SQL Server
57
65
  - `TLPT_AZURE_SQL_URI`: Azure SQL Server URI
58
66
  - Example: `yourserver.database.windows.net`
@@ -109,6 +117,10 @@ See ENVIRONMENT_VARIABLES.md for details.
109
117
  - Default: `2024-07-01.20.0`
110
118
  - Used by: batch_task_runner.py
111
119
 
120
+ - `AZ_BATCH_NODE_CUSTOM_MOUNT`: Path on the Azure Batch VM node to mount into the Docker container's working directory (`/home/ubuntu/wd`). This should be a directory accessible to the task on the node. Use Azure Batch built-in environment variables to reference standard node paths — for example, `$AZ_BATCH_NODE_MOUNTS_DIR/<mountname>` (a virtual file system mounted on the node) or `$AZ_BATCH_TASK_WORKING_DIR` (the task's own working directory). See [Azure Batch: Files and directories](https://learn.microsoft.com/en-us/azure/batch/files-and-directories) for the full list of available node environment variables.
121
+ - Default: `$AZ_BATCH_NODE_MOUNTS_DIR/datadisk`
122
+ - Used by: batch_task_runner.py
123
+
112
124
  ### Cache Configuration
113
125
  - `TLPT_ADLS_CACHE_DIR`: Directory for ADLS cache files
114
126
  - Default: `C:/Temp/tlpytools/adls`
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: tlpytools
3
- Version: 0.2.6
3
+ Version: 0.2.8
4
4
  Summary: TransLink's Python Tools - A comprehensive toolkit for transportation modeling and forecasting
5
5
  Project-URL: Homepage, https://github.com/TransLinkForecasting/tlpytools
6
6
  Project-URL: Bug Tracker, https://github.com/TransLinkForecasting/tlpytools/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "tlpytools"
7
- version = "0.2.6"
7
+ version = "0.2.8"
8
8
  description = "TransLink's Python Tools - A comprehensive toolkit for transportation modeling and forecasting"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10.0, <3.13"
@@ -2,7 +2,7 @@
2
2
  TLPyTools - A set of tools for building models at the TransLink Forecasting Team
3
3
  """
4
4
 
5
- __version__ = "0.2.6"
5
+ __version__ = "0.2.8"
6
6
 
7
7
  # Core modules that should always be available (minimal dependencies)
8
8
  from . import log
@@ -6,7 +6,11 @@ import time
6
6
  from functools import wraps
7
7
  from io import BytesIO
8
8
 
9
- from azure.core.exceptions import HttpResponseError, ResourceNotFoundError
9
+ from azure.core.exceptions import (
10
+ HttpResponseError,
11
+ ResourceNotFoundError,
12
+ ServiceRequestError,
13
+ )
10
14
  from azure.storage.filedatalake import (
11
15
  DataLakeDirectoryClient,
12
16
  # DataLakeServiceClient,
@@ -104,9 +108,19 @@ class adls_util(UnifiedLogger):
104
108
 
105
109
  # Optimized chunk sizes for different file sizes
106
110
  UPLOAD_CHUNK_SIZE_SMALL = 4 * 1024 * 1024 # 4MB for files < 100MB
107
- UPLOAD_CHUNK_SIZE_MEDIUM = 16 * 1024 * 1024 # 16MB for files < 1GB
111
+ UPLOAD_CHUNK_SIZE_MEDIUM = (
112
+ 8 * 1024 * 1024
113
+ ) # 8MB for files < 1GB (reduced to limit per-write socket time)
108
114
  UPLOAD_CHUNK_SIZE_LARGE = 100 * 1024 * 1024 # 100MB for files >= 1GB
109
115
  MAX_CONCURRENCY_DEFAULT = 4 # Default parallel threads for large files
116
+ UPLOAD_MAX_RETRIES = 3 # Retries on connection/timeout errors
117
+ # Dynamic socket timeout: per-chunk timeout = chunk_size / (MIN_TRANSFER_SPEED_MBPS * 125000) * FACTOR
118
+ MIN_TRANSFER_SPEED_MBPS = 2 # Conservative minimum speed (Mbps) — set lower than worst-case user connection
119
+ SOCKET_TIMEOUT_SAFETY_FACTOR = (
120
+ 3 # Multiply calculated per-chunk transfer time by this before using as timeout
121
+ )
122
+ MIN_SOCKET_TIMEOUT_SECS = 60 # Floor: never set a socket timeout below this value
123
+ DOWNLOAD_CHUNK_SIZE_BYTES = 4 * 1024 * 1024 # Azure SDK default download chunk size
110
124
 
111
125
  def __init__(self, logger: logging.Logger = None):
112
126
  """
@@ -150,6 +164,19 @@ class adls_util(UnifiedLogger):
150
164
  except ResourceNotFoundError:
151
165
  return False
152
166
 
167
+ @classmethod
168
+ def _calculate_chunk_timeout(cls, chunk_size_bytes: int) -> int:
169
+ """Socket read/write timeout for one chunk at MIN_TRANSFER_SPEED_MBPS with safety margin."""
170
+ speed_bytes_per_sec = cls.MIN_TRANSFER_SPEED_MBPS * 1024 * 1024 / 8
171
+ return max(
172
+ int(
173
+ chunk_size_bytes
174
+ / speed_bytes_per_sec
175
+ * cls.SOCKET_TIMEOUT_SAFETY_FACTOR
176
+ ),
177
+ cls.MIN_SOCKET_TIMEOUT_SECS,
178
+ )
179
+
153
180
  @classmethod
154
181
  def upload_file_to_directory(
155
182
  cls,
@@ -213,20 +240,38 @@ class adls_util(UnifiedLogger):
213
240
  else:
214
241
  max_concurrency = 1 # Single-threaded for small files
215
242
 
216
- # upload file with optimized settings
217
- with open(file=file_path, mode="rb") as data:
218
- # to adjust additional options, see: https://learn.microsoft.com/en-us/python/api/azure-storage-file-datalake/azure.storage.filedatalake.datalakefileclient?view=azure-python#azure-storage-filedatalake-datalakefileclient-upload-data
219
- file_client.upload_data(
220
- data,
221
- overwrite=True,
222
- timeout=cls.UPLOAD_TIMEOUT_SECS,
223
- chunk_size=chunk_size,
224
- max_concurrency=max_concurrency, # Enable parallel uploads
225
- )
226
- # alternative method that is more verbose
227
- # file_client.create_file()
228
- # file_client.append_data(data, offset=0, length=len(data))
229
- # file_client.flush_data(len(data))
243
+ # Per-chunk socket timeout scaled to minimum expected transfer speed
244
+ socket_timeout = cls._calculate_chunk_timeout(chunk_size)
245
+
246
+ # upload file with retry logic for transient connection/timeout errors
247
+ for attempt in range(cls.UPLOAD_MAX_RETRIES):
248
+ try:
249
+ with open(file=file_path, mode="rb") as data:
250
+ file_client.upload_data(
251
+ data,
252
+ overwrite=True,
253
+ timeout=cls.UPLOAD_TIMEOUT_SECS,
254
+ chunk_size=chunk_size,
255
+ max_concurrency=max_concurrency,
256
+ read_timeout=socket_timeout,
257
+ connection_timeout=socket_timeout,
258
+ )
259
+ break # success
260
+ except ServiceRequestError as e:
261
+ if attempt < cls.UPLOAD_MAX_RETRIES - 1:
262
+ wait_secs = 5 * (2**attempt) # 5s, 10s
263
+ logger.warning(
264
+ "Upload attempt %d/%d failed for %s (connection error, socket_timeout=%ds): %s. Retrying in %ds...",
265
+ attempt + 1,
266
+ cls.UPLOAD_MAX_RETRIES,
267
+ local_file_name,
268
+ socket_timeout,
269
+ e,
270
+ wait_secs,
271
+ )
272
+ time.sleep(wait_secs)
273
+ else:
274
+ raise
230
275
 
231
276
  logger.debug(
232
277
  "Successfully uploaded %s (size: %.2f MB, chunk: %.1f MB, concurrency: %d)",
@@ -273,9 +318,16 @@ class adls_util(UnifiedLogger):
273
318
  else:
274
319
  max_concurrency = 1 # Single-threaded for small files
275
320
 
321
+ # Per-chunk socket timeout scaled to minimum expected transfer speed
322
+ socket_timeout = cls._calculate_chunk_timeout(cls.DOWNLOAD_CHUNK_SIZE_BYTES)
323
+
276
324
  # Download with parallel streams for better performance
277
325
  # Note: Azure SDK handles chunk sizing internally for downloads
278
- download_stream = file_client.download_file(max_concurrency=max_concurrency)
326
+ download_stream = file_client.download_file(
327
+ max_concurrency=max_concurrency,
328
+ read_timeout=socket_timeout,
329
+ connection_timeout=socket_timeout,
330
+ )
279
331
  data_bytes = download_stream.readall()
280
332
  bytes_io = BytesIO(data_bytes)
281
333
 
@@ -227,10 +227,13 @@ class BatchTaskRunner:
227
227
 
228
228
  # Build base container run options
229
229
  # - /dev/shm is mounted for shared memory access, which is required for memory intensive programs
230
- # - azure vm datadisk is mounted to docker container working directory to perform model runs
230
+ # - AZ_BATCH_NODE_CUSTOM_MOUNT is the path on the Azure Batch VM node mounted to the docker container working directory
231
+ node_mount_path = get_env_var(
232
+ "AZ_BATCH_NODE_CUSTOM_MOUNT", "$AZ_BATCH_NODE_MOUNTS_DIR/datadisk"
233
+ )
231
234
  container_run_options = (
232
235
  "--workdir /home/ubuntu/wd --rm --volume /dev/shm:/dev/shm "
233
- "--volume $AZ_BATCH_NODE_MOUNTS_DIR/datadisk:/home/ubuntu/wd"
236
+ f"--volume {node_mount_path}:/home/ubuntu/wd"
234
237
  )
235
238
 
236
239
  # Add entrypoint only if both override_python_env and override_python_command are provided
@@ -69,8 +69,12 @@ class OrcaLogger:
69
69
  """
70
70
  Centralized logger class for ORCA orchestrator and related utilities.
71
71
 
72
- Each instance creates an isolated logger for a specific scenario, ensuring
73
- proper separation between different scenario runs on the same VM.
72
+ Each instance creates a fully isolated logger for a specific scenario.
73
+ The logger name is built from a git-derived base (tag > SHA > random UUID)
74
+ combined with an 8-character MD5 hash of the scenario folder name, e.g.
75
+ ``orca_1cd9559.a3f2b891``. This guarantees that two OrcaOrchestrator
76
+ instances initialised in the same Python session always own separate
77
+ ``logging.Logger`` objects, preventing cross-scenario log contamination.
74
78
  """
75
79
 
76
80
  def __init__(self, log_file_path: str | None = None, log_level: int = logging.INFO):
@@ -120,7 +124,8 @@ class OrcaLogger:
120
124
 
121
125
  def _setup_logger(self):
122
126
  """Set up the logger with consistent formatting and handlers."""
123
- # Determine logger name from git tag, git SHA, or random session ID
127
+ # Logger name is unique per scenario (git-base + scenario-folder hash),
128
+ # so getLogger always returns a fresh object; clearing handlers is safe.
124
129
  logger_name = self._resolve_logger_name()
125
130
 
126
131
  # Create logger
@@ -174,14 +179,22 @@ class OrcaLogger:
174
179
  """
175
180
  Resolve a stable logger name using git metadata when available.
176
181
 
177
- Priority:
182
+ The name is made unique per scenario by appending the scenario folder name
183
+ (derived from the log file path), preventing logger-object sharing when
184
+ multiple OrcaOrchestrator instances are created in the same Python session.
185
+
186
+ Priority for base name:
178
187
  1. Git tag pointing at HEAD -> f"orca_{tag}"
179
188
  2. Git SHA (first 7 chars) -> f"orca_{sha}"
180
189
  3. Random session UUID -> f"session_{uuid8}"
190
+
191
+ Scenario suffix: grandparent directory of the log file
192
+ (i.e. <scenario>/logs/orca_*.log -> <scenario>)
181
193
  """
182
194
  project_cwd = os.getcwd()
195
+ base_name = None
196
+
183
197
  try:
184
- # Priority 1: git tag pointing exactly at HEAD
185
198
  tag_result = subprocess.run(
186
199
  ["git", "describe", "--tags", "--exact-match", "HEAD"],
187
200
  capture_output=True,
@@ -192,30 +205,45 @@ class OrcaLogger:
192
205
  if tag_result.returncode == 0:
193
206
  git_version = tag_result.stdout.strip()
194
207
  if git_version:
195
- return f"orca_{git_version}"
208
+ base_name = f"orca_{git_version}"
196
209
  except Exception:
197
210
  pass
198
211
 
199
- try:
200
- # Priority 2: short git SHA (7 characters)
201
- sha_result = subprocess.run(
202
- ["git", "rev-parse", "--short=7", "HEAD"],
203
- capture_output=True,
204
- text=True,
205
- timeout=5,
206
- cwd=project_cwd,
207
- )
208
- if sha_result.returncode == 0:
209
- git_sha = sha_result.stdout.strip()
210
- if git_sha:
211
- return f"orca_{git_sha}"
212
- except Exception:
213
- pass
212
+ if base_name is None:
213
+ try:
214
+ sha_result = subprocess.run(
215
+ ["git", "rev-parse", "--short=7", "HEAD"],
216
+ capture_output=True,
217
+ text=True,
218
+ timeout=5,
219
+ cwd=project_cwd,
220
+ )
221
+ if sha_result.returncode == 0:
222
+ git_sha = sha_result.stdout.strip()
223
+ if git_sha:
224
+ base_name = f"orca_{git_sha}"
225
+ except Exception:
226
+ pass
227
+
228
+ if base_name is None:
229
+ import uuid
230
+
231
+ base_name = f"session_{uuid.uuid4().hex[:8]}"
214
232
 
215
- # Priority 3: random session UUID fallback
216
- import uuid
233
+ # Append a short hash of the scenario folder so each orchestrator gets its own logger tree
234
+ if self._log_file_path:
235
+ try:
236
+ import hashlib
237
+ from pathlib import Path as _Path
238
+
239
+ scenario_folder = _Path(self._log_file_path).parent.parent.name
240
+ if scenario_folder:
241
+ suffix = hashlib.md5(scenario_folder.encode()).hexdigest()[:8]
242
+ return f"{base_name}.{suffix}"
243
+ except Exception:
244
+ pass
217
245
 
218
- return f"session_{uuid.uuid4().hex[:8]}"
246
+ return base_name
219
247
 
220
248
  def _log_system_info(self):
221
249
  """
@@ -346,11 +374,19 @@ def get_orca_logger(
346
374
  log_level: int = logging.INFO,
347
375
  ):
348
376
  """
349
- Get the ORCA orchestrator logger or a child self.logger.
377
+ Create and return an ORCA logger (or a named child of one).
378
+
379
+ Each call constructs a new OrcaLogger whose underlying ``logging.Logger``
380
+ name encodes both the git revision and an 8-char hash of the scenario
381
+ folder derived from ``log_file_path``. This makes every scenario
382
+ instance in a session use its own isolated logger tree, so handlers
383
+ and log output never bleed between concurrent or sequential runs.
350
384
 
351
385
  Args:
352
- name: Optional name for a child logger
353
- log_file_path: Optional path to the log file
386
+ name: If provided, returns a child logger with this suffix
387
+ (e.g. ``"orchestrator"`` yields ``orca_<sha>.<hash>.orchestrator``).
388
+ log_file_path: Path to the scenario log file; used to derive the
389
+ scenario-specific hash component of the logger name.
354
390
  log_level: Logging level (e.g., logging.DEBUG, logging.INFO). Defaults to INFO.
355
391
 
356
392
  Returns:
@@ -1761,6 +1797,10 @@ class OrcaScenario:
1761
1797
 
1762
1798
  with zipfile.ZipFile(zip_path, "w", **zip_kwargs) as zf:
1763
1799
  for root, dirs, files in os.walk(dir_path, topdown=True):
1800
+ # Sort dirs and files for deterministic archive member order
1801
+ # across machines with different filesystem orderings.
1802
+ dirs.sort()
1803
+ files = sorted(files)
1764
1804
  # Filter directories for traversal
1765
1805
  dirs_to_remove = set()
1766
1806
  for d in dirs:
@@ -1849,7 +1889,7 @@ class OrcaScenario:
1849
1889
  full_pattern = os.path.join(base_dir, pattern)
1850
1890
 
1851
1891
  # Find all files matching the pattern
1852
- matching_files = glob.glob(full_pattern, recursive=True)
1892
+ matching_files = sorted(glob.glob(full_pattern, recursive=True))
1853
1893
 
1854
1894
  # Delete each file
1855
1895
  for file_path in matching_files:
@@ -3621,10 +3661,11 @@ class OrcaOrchestrator:
3621
3661
  pythonpath_cmd = (
3622
3662
  f'set "PYTHONHOME=" && '
3623
3663
  f'set "PYTHONPATH={ORCA_DIR};{step_directory}" && '
3664
+ f'set "PYTHONHASHSEED=0" && '
3624
3665
  )
3625
3666
  else: # Unix/Linux/Mac
3626
3667
  # On Unix-like systems, use export command
3627
- pythonpath_cmd = f"unset PYTHONHOME && export PYTHONPATH={ORCA_DIR}:{step_directory} && "
3668
+ pythonpath_cmd = f"unset PYTHONHOME && export PYTHONPATH={ORCA_DIR}:{step_directory} && export PYTHONHASHSEED=0 && "
3628
3669
 
3629
3670
  # Modify the command to ensure environment can be found
3630
3671
  modified_command = f"{pythonpath_cmd}{command}"
@@ -4171,9 +4212,23 @@ class OrcaOrchestrator:
4171
4212
  adls_base = get_env_var("ORCA_ADLS_URL", required=True)
4172
4213
  adls_url = f"https://{adls_base}"
4173
4214
 
4174
- adls_container = get_env_var("ORCA_ADLS_CONTAINER", required=True)
4215
+ adls_container_raw = get_env_var("ORCA_ADLS_CONTAINER_PATH", required=True)
4216
+ # The filesystem name must be a single path component; split any sub-path out
4217
+ container_parts = adls_container_raw.split("/", 1)
4218
+ adls_container = container_parts[0]
4219
+ container_path_prefix = container_parts[1] if len(container_parts) > 1 else ""
4220
+ if container_path_prefix:
4221
+ self.logger.debug(
4222
+ "ORCA_ADLS_CONTAINER_PATH contains a path prefix '%s'; prepending to folder",
4223
+ container_path_prefix,
4224
+ )
4175
4225
 
4176
- adls_folder = self.project_folder_override or "proj_unnamed"
4226
+ base_folder = self.project_folder_override or "proj_unnamed"
4227
+ adls_folder = (
4228
+ f"{container_path_prefix}/{base_folder}"
4229
+ if container_path_prefix
4230
+ else base_folder
4231
+ )
4177
4232
  if self.project_folder_override:
4178
4233
  self.logger.info("Using project folder override: %s", adls_folder)
4179
4234
 
@@ -6601,7 +6656,7 @@ class OrcaOrchestrator:
6601
6656
  # Find all output archives that need to be backed up
6602
6657
  backup_operations = []
6603
6658
 
6604
- for filename in os.listdir(outputs_dir):
6659
+ for filename in sorted(os.listdir(outputs_dir)):
6605
6660
  if not filename.endswith(".zip"):
6606
6661
  continue
6607
6662
 
@@ -7738,11 +7793,10 @@ class OrcaUtil:
7738
7793
  os.startfile(folder_path)
7739
7794
 
7740
7795
  button.on_click(on_button_clicked)
7741
- print(f"\n{folder_path}")
7742
7796
  display(button)
7743
7797
  except (ImportError, NameError):
7744
7798
  # Fallback for non-Jupyter environments
7745
- print(f"\n{folder_name}: {folder_path}")
7799
+ print(f"{folder_name}: {folder_path}")
7746
7800
 
7747
7801
  @staticmethod
7748
7802
  def check_cloud_config(orchestrator: "OrcaOrchestrator") -> dict:
@@ -7787,7 +7841,7 @@ class OrcaUtil:
7787
7841
  # Required environment variables for cloud operations
7788
7842
  required_env_vars = [
7789
7843
  "ORCA_ADLS_URL",
7790
- "ORCA_ADLS_CONTAINER",
7844
+ "ORCA_ADLS_CONTAINER_PATH",
7791
7845
  "BATCH_ACCOUNT_ENDPOINT",
7792
7846
  "IMAGE_REGISTRY_ENDPOINT",
7793
7847
  "AZURE_SUBSCRIPTION_ID",
@@ -7844,7 +7898,7 @@ class OrcaUtil:
7844
7898
 
7845
7899
  # Get cloud configuration from environment variables
7846
7900
  adls_url = os.getenv("ORCA_ADLS_URL", "")
7847
- adls_container = os.getenv("ORCA_ADLS_CONTAINER", "")
7901
+ adls_container = os.getenv("ORCA_ADLS_CONTAINER_PATH", "")
7848
7902
  adls_folder = orchestrator.project_folder_override or ""
7849
7903
 
7850
7904
  # Print detailed configuration status
@@ -7915,7 +7969,9 @@ class OrcaUtil:
7915
7969
  print(
7916
7970
  " 1. Set required environment variables in your .env file (see ENVIRONMENT_VARIABLES.md)"
7917
7971
  )
7918
- print(" 2. Ensure ORCA_ADLS_URL and ORCA_ADLS_CONTAINER are set correctly")
7972
+ print(
7973
+ " 2. Ensure ORCA_ADLS_URL and ORCA_ADLS_CONTAINER_PATH are set correctly"
7974
+ )
7919
7975
  print(" 3. Install and authenticate Azure CLI (az login)")
7920
7976
  print(" 4. Verify managed identity or CLI credential is enabled")
7921
7977
 
@@ -558,9 +558,9 @@ class TestOrcaOrchestrator(unittest.TestCase):
558
558
  "ORCA_ADLS_URL", env_vars, "ORCA_ADLS_URL missing from .env.example"
559
559
  )
560
560
  self.assertIn(
561
- "ORCA_ADLS_CONTAINER",
561
+ "ORCA_ADLS_CONTAINER_PATH",
562
562
  env_vars,
563
- "ORCA_ADLS_CONTAINER missing from .env.example",
563
+ "ORCA_ADLS_CONTAINER_PATH missing from .env.example",
564
564
  )
565
565
 
566
566
  with patch.dict(os.environ, env_vars):
@@ -570,8 +570,13 @@ class TestOrcaOrchestrator(unittest.TestCase):
570
570
  adls_url, adls_container, adls_folder = orchestrator.get_adls_config()
571
571
 
572
572
  self.assertEqual(adls_url, f"https://{env_vars['ORCA_ADLS_URL']}")
573
- self.assertEqual(adls_container, env_vars["ORCA_ADLS_CONTAINER"])
574
- self.assertEqual(adls_folder, "test_folder")
573
+ container_parts = env_vars["ORCA_ADLS_CONTAINER_PATH"].split("/", 1)
574
+ self.assertEqual(adls_container, container_parts[0])
575
+ container_prefix = container_parts[1] if len(container_parts) > 1 else ""
576
+ expected_folder = (
577
+ f"{container_prefix}/test_folder" if container_prefix else "test_folder"
578
+ )
579
+ self.assertEqual(adls_folder, expected_folder)
575
580
 
576
581
  def test_input_data_initialization(self):
577
582
  """Test that input_data configuration is properly loaded."""