tlpytools 0.2.13__tar.gz → 0.2.14__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 (57) hide show
  1. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/copilot-instructions.md +2 -2
  2. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/skills/prepare-official-release/SKILL.md +1 -1
  3. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/workflows/deploy.yml +1 -1
  4. {tlpytools-0.2.13 → tlpytools-0.2.14}/CHANGELOG.md +16 -0
  5. {tlpytools-0.2.13 → tlpytools-0.2.14}/DEVELOPER_GUIDE.md +2 -2
  6. {tlpytools-0.2.13 → tlpytools-0.2.14}/PKG-INFO +1 -1
  7. {tlpytools-0.2.13 → tlpytools-0.2.14}/pyproject.toml +1 -1
  8. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/__init__.py +1 -1
  9. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/README.md +11 -1
  10. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/batch_task_runner.py +50 -18
  11. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/orchestrator.py +2 -1
  12. tlpytools-0.2.14/src/tlpytools/orca/project_utils.py +16 -0
  13. {tlpytools-0.2.13 → tlpytools-0.2.14}/uv.lock +1 -1
  14. {tlpytools-0.2.13 → tlpytools-0.2.14}/.env.example +0 -0
  15. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/skills/README.md +0 -0
  16. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/workflows/code-formatting-pr.yml +0 -0
  17. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/workflows/code-formatting.yml +0 -0
  18. {tlpytools-0.2.13 → tlpytools-0.2.14}/.github/workflows/test.yml +0 -0
  19. {tlpytools-0.2.13 → tlpytools-0.2.14}/.gitignore +0 -0
  20. {tlpytools-0.2.13 → tlpytools-0.2.14}/.pre-commit-config.yaml +0 -0
  21. {tlpytools-0.2.13 → tlpytools-0.2.14}/.python-version +0 -0
  22. {tlpytools-0.2.13 → tlpytools-0.2.14}/ENVIRONMENT_VARIABLES.md +0 -0
  23. {tlpytools-0.2.13 → tlpytools-0.2.14}/Makefile +0 -0
  24. {tlpytools-0.2.13 → tlpytools-0.2.14}/README.md +0 -0
  25. {tlpytools-0.2.13 → tlpytools-0.2.14}/docs/adls_server.md +0 -0
  26. {tlpytools-0.2.13 → tlpytools-0.2.14}/docs/azure_credential_manager.md +0 -0
  27. {tlpytools-0.2.13 → tlpytools-0.2.14}/docs/unified_logging.md +0 -0
  28. {tlpytools-0.2.13 → tlpytools-0.2.14}/requirements.txt +0 -0
  29. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/examples/batchtask.py +0 -0
  30. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/examples/data_files/example.csv +0 -0
  31. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/examples/mydataproject.py +0 -0
  32. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/examples/readwritedata.py +0 -0
  33. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/examples/unified_logging.py +0 -0
  34. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/adls_server.py +0 -0
  35. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/azure_credential.py +0 -0
  36. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/config.py +0 -0
  37. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/data.py +0 -0
  38. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/data_store.py +0 -0
  39. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/env_config.py +0 -0
  40. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/log.py +0 -0
  41. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/__init__.py +0 -0
  42. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/__main__.py +0 -0
  43. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/cli.py +0 -0
  44. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/orca_model_config_barebone.yaml +0 -0
  45. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/orca/orca_model_config_example.yaml +0 -0
  46. {tlpytools-0.2.13 → tlpytools-0.2.14}/src/tlpytools/sql_server.py +0 -0
  47. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/README.md +0 -0
  48. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/__init__.py +0 -0
  49. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/conftest.py +0 -0
  50. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/run_tests.py +0 -0
  51. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_azure_credential.py +0 -0
  52. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_basic.py +0 -0
  53. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_core.py +0 -0
  54. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_orca_cli_batch_options.py +0 -0
  55. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_orca_integration.py +0 -0
  56. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_orca_resume_cloud.py +0 -0
  57. {tlpytools-0.2.13 → tlpytools-0.2.14}/tests/test_orca_unit.py +0 -0
@@ -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.13.tar.gz`
102
- - `dist/tlpytools-0.2.13-py3-none-any.whl`
101
+ - `dist/tlpytools-0.2.14.tar.gz`
102
+ - `dist/tlpytools-0.2.14-py3-none-any.whl`
103
103
 
104
104
  ### 5) Run
105
105
  - ORCA CLI (module form):
@@ -443,7 +443,7 @@ Run all tests in sequence (not parallel) to avoid resource conflicts:
443
443
  **Example 3 - Repository Change:**
444
444
  ```markdown
445
445
  **Update to Repository-Specific Notes:**
446
- - **Python version:** Updated to >=3.11, <3.14 for the 0.2.13 release
446
+ - **Python version:** Updated to >=3.11, <3.14 for the 0.2.14 release
447
447
  - Previous versions used 3.10
448
448
  - Update affects CI workflows and local development
449
449
  - All dependencies verified compatible with 3.12
@@ -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.13)'
7
+ description: 'Version number to release (e.g., 0.2.14)'
8
8
  required: true
9
9
  type: string
10
10
  prerelease:
@@ -2,6 +2,22 @@
2
2
 
3
3
  All notable changes to TLPyTools will be documented in this file.
4
4
 
5
+ ## [0.2.14]
6
+
7
+ ### Fixed
8
+ - **Azure Batch task submission failed with `InvalidPropertyValue` for long project names with sub
9
+ folders** (task IDs over 64 characters, for example
10
+ `proj_asim16_updates/v16memmiser/final_mem_optimized_64g`): the task ID now uses only the part of
11
+ the project name before the first `/` or `\`, cut to 24 characters, with characters Azure Batch
12
+ does not accept replaced by `-`. The full project path is still passed to the container with
13
+ `--project`, so ADLS upload/download paths keep their sub folders
14
+ - **Duplicate-task detection treated different sub folders of one project as the same project:**
15
+ matching now uses the full `--project` value from the task command line (falling back to the task
16
+ ID name for older tasks), and parses task IDs whose project name contains `-`
17
+ - **Project folders with backslashes or stray slashes** (`proj\sub`, `/proj//sub/`) are now
18
+ normalized to `proj/sub` (new `tlpytools.orca.project_utils.normalize_project_folder`) before
19
+ being used for ADLS paths, orchestrator state and the Batch command line
20
+
5
21
  ## [0.2.13]
6
22
 
7
23
  ### Added
@@ -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.13`)
203
+ - **Version number**: Enter the new version (e.g., `0.2.14`)
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.13 # Replace with your version
222
+ pip install tlpytools==0.2.14 # Replace with your version
223
223
 
224
224
  # Test installation in a fresh environment
225
225
  python -c "import tlpytools; print(tlpytools.__version__)"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: tlpytools
3
- Version: 0.2.13
3
+ Version: 0.2.14
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.13"
7
+ version = "0.2.14"
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.11,<3.14"
@@ -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.13"
5
+ __version__ = "0.2.14"
6
6
 
7
7
  # Core modules that should always be available (minimal dependencies)
8
8
  from . import log
@@ -170,6 +170,10 @@ The orchestrator determines the ADLS project folder using the following priority
170
170
 
171
171
  This allows flexible project organization in cloud storage while maintaining backwards compatibility.
172
172
 
173
+ **Project folder format:** the project can include sub folders, for example `proj_asim16_updates/v16memmiser/final_mem_optimized`.
174
+ The value is normalized before use (backslashes become `/`, leading/trailing/duplicate slashes and `.`/`..` segments are dropped),
175
+ so `proj\sub\run` and `/proj//sub/run/` both resolve to `proj/sub/run`. The normalized path is used for all ADLS uploads and
176
+ downloads, and is stored as `project_name` in the state file.
173
177
  ## Configuration Files
174
178
 
175
179
  ### File Locations and Naming
@@ -1135,7 +1139,7 @@ python -m tlpytools.orca.batch_task_runner --job-id job_large --project my_proje
1135
1139
  | Argument | Required | Default | Description |
1136
1140
  |----------|----------|---------|-------------|
1137
1141
  | `--job-id` | Yes | - | Batch job ID where the task will be submitted |
1138
- | `--project` | Yes | - | Project name (used in task ID generation) |
1142
+ | `--project` | Yes | - | Project name or ADLS project folder path (may include sub folders); passed unchanged (normalized to `/` separators) to the container as `--project`. Only the first path segment, cut to 24 characters, is used in the task ID (see below) |
1139
1143
  | `--scenario` | Yes | - | Scenario name for the ORCA task |
1140
1144
  | `--override-python-env` | No | Docker image default | Python environment path inside the container |
1141
1145
  | `--override-python-command` | No | Docker image default | Python command/script to run inside the container |
@@ -1155,6 +1159,8 @@ python -m tlpytools.orca.batch_task_runner --job-id job_large --project my_proje
1155
1159
  ### How It Works
1156
1160
 
1157
1161
  1. **Duplicate Detection**: Checks for existing tasks with the same project and scenario name
1162
+ - The full `--project` value (including sub folders) recorded in each task's command line is compared, so
1163
+ `proj_a/x` and `proj_a/y` are different projects; tasks without `--project` fall back to the task ID name
1158
1164
  - A task that is already `active`, `preparing` or `running` is monitored instead of resubmitted
1159
1165
  (the newest one, if several); requested execution/resume options are NOT applied to it
1160
1166
  - A successfully `completed` task blocks submission (it would overwrite finished results)
@@ -1162,6 +1168,10 @@ python -m tlpytools.orca.batch_task_runner --job-id job_large --project my_proje
1162
1168
  - Provides clear user-facing messages with guidance on how to proceed
1163
1169
  - Can be bypassed with `--skip-duplicate-check` flag if needed
1164
1170
  2. **Task Submission**: Creates a unique task ID and submits it to the specified Azure Batch job
1171
+ - Task ID format: `YYYYMMDD-HHMMSS-<project>-<7 hex chars>`. Azure Batch only accepts alphanumerics, `-` and `_`,
1172
+ up to 64 characters, so `<project>` is the part of the project name before the first `/` or `\`, cut to
1173
+ 24 characters, with any other character replaced by `-` (for example
1174
+ `proj_asim16_updates/v16memmiser/final_mem_optimized` -> `proj_asim16_updates`). IDs are at most 48 characters.
1165
1175
  3. **Status Monitoring**: Polls the task status at regular intervals
1166
1176
  4. **Early Exit**: Stops polling when the task reaches the 'completed' state, or fails
1167
1177
  5. **Failure Detection**: Azure Batch reports a task whose command exited non-zero as `completed`
@@ -19,6 +19,7 @@ from uuid import uuid4
19
19
  import requests
20
20
 
21
21
  from ..env_config import get_env_var
22
+ from .project_utils import normalize_project_folder
22
23
 
23
24
  # (connect, read) seconds; a stalled Batch REST call must not hang a submission thread forever
24
25
  _REQUEST_TIMEOUT_SECONDS = (10, 60)
@@ -186,22 +187,25 @@ class BatchTaskRunner:
186
187
  self.logger.debug("Retrieving Azure access token for Batch API...")
187
188
  return self.credential_manager.get_batch_access_token()
188
189
 
190
+ @staticmethod
191
+ def _sanitize_project_name(project_name: str, max_length: int = 24) -> str:
192
+ """Reduce a project name to a form safe for Azure Batch task IDs.
193
+
194
+ Keeps only the part before the first forward/backward slash, truncates
195
+ to max_length characters, and replaces characters other than ASCII
196
+ alphanumerics, dash (-) and underscore (_) with dashes.
197
+ """
198
+ name = (normalize_project_folder(project_name) or "proj_unnamed").split("/")[0]
199
+ name = name[:max_length]
200
+ return "".join(
201
+ c if (c.isascii() and c.isalnum()) or c in ("-", "_") else "-" for c in name
202
+ )
203
+
189
204
  def _generate_task_id(self, project_name: str) -> str:
190
205
  """Generate a unique task ID similar to the Synapse pipeline"""
191
206
  timestamp = datetime.now().strftime("%Y%m%d-%H%M%S")
192
207
  guid_prefix = str(uuid4())[:7]
193
- # Sanitize project_name: Azure Batch task IDs can only contain alphanumeric, dash (-), and underscore (_)
194
- sanitized_chars = []
195
- for char in project_name:
196
- if char.isalnum() or char in ("-", "_"):
197
- sanitized_chars.append(char)
198
- elif char == "/":
199
- # Replace forward slashes (from subfolders) with dashes
200
- sanitized_chars.append("-")
201
- else:
202
- # Replace other invalid characters with dashes
203
- sanitized_chars.append("-")
204
- sanitized_project_name = "".join(sanitized_chars)
208
+ sanitized_project_name = self._sanitize_project_name(project_name)
205
209
 
206
210
  if sanitized_project_name != project_name:
207
211
  self.logger.debug(
@@ -301,7 +305,8 @@ class BatchTaskRunner:
301
305
  raise ValueError("resume_step requires resume_iteration to also be set")
302
306
 
303
307
  options = (
304
- f"--scenario {scenario_name} --project {project_name} "
308
+ f"--scenario {scenario_name} "
309
+ f"--project {normalize_project_folder(project_name) or project_name} "
305
310
  "--action run_model --mode cloud_production"
306
311
  )
307
312
  if execution_options and execution_options != "full":
@@ -482,6 +487,22 @@ class BatchTaskRunner:
482
487
 
483
488
  return tasks
484
489
 
490
+ @staticmethod
491
+ def _full_project_from_args(args: list[str], fallback: str) -> str:
492
+ """Return the full (normalized) --project value from a split command line.
493
+
494
+ The task ID only holds a truncated first path segment, so the command line
495
+ is the only place the complete project folder survives. Falls back to the
496
+ task-ID-derived name for tasks submitted without --project.
497
+ """
498
+ try:
499
+ idx = args.index("--project")
500
+ if idx + 1 < len(args):
501
+ return normalize_project_folder(args[idx + 1]) or fallback
502
+ except ValueError:
503
+ pass
504
+ return fallback
505
+
485
506
  def _extract_project_scenario_from_task(
486
507
  self, task: dict[str, Any]
487
508
  ) -> tuple[str, str] | None:
@@ -495,8 +516,8 @@ class BatchTaskRunner:
495
516
  parts = task_id.split("-")
496
517
  if len(parts) >= 4:
497
518
  # Task ID format: timestamp-project-guid
498
- # project_name is the third part
499
- project_name = parts[2]
519
+ # project_name is everything between the timestamp and the guid
520
+ project_name = "-".join(parts[2:-1])
500
521
 
501
522
  # Try to extract scenario from commandLine
502
523
  command_line = task.get("commandLine", "")
@@ -507,7 +528,10 @@ class BatchTaskRunner:
507
528
  scenario_idx = cmd_parts.index("--scenario")
508
529
  if scenario_idx + 1 < len(cmd_parts):
509
530
  scenario_name = cmd_parts[scenario_idx + 1]
510
- return (project_name, scenario_name)
531
+ return (
532
+ self._full_project_from_args(cmd_parts, project_name),
533
+ scenario_name,
534
+ )
511
535
  except (ValueError, IndexError):
512
536
  pass
513
537
 
@@ -521,7 +545,10 @@ class BatchTaskRunner:
521
545
  scenario_idx = opts_parts.index("--scenario")
522
546
  if scenario_idx + 1 < len(opts_parts):
523
547
  scenario_name = opts_parts[scenario_idx + 1]
524
- return (project_name, scenario_name)
548
+ return (
549
+ self._full_project_from_args(opts_parts, project_name),
550
+ scenario_name,
551
+ )
525
552
  except (ValueError, IndexError):
526
553
  pass
527
554
 
@@ -559,12 +586,17 @@ class BatchTaskRunner:
559
586
  "existing_tasks": [],
560
587
  }
561
588
 
589
+ sanitized_project = self._sanitize_project_name(project_name)
590
+ full_project = normalize_project_folder(project_name)
562
591
  matching_tasks = []
563
592
  for task in tasks:
564
593
  task_info = self._extract_project_scenario_from_task(task)
565
594
  if task_info:
566
595
  task_project, task_scenario = task_info
567
- if task_project == project_name and task_scenario == scenario_name:
596
+ if (
597
+ task_project in (full_project, sanitized_project)
598
+ and task_scenario == scenario_name
599
+ ):
568
600
  matching_tasks.append(task)
569
601
 
570
602
  if not matching_tasks:
@@ -18,6 +18,7 @@ from typing import Any
18
18
  import yaml
19
19
 
20
20
  from ..env_config import get_env_var
21
+ from .project_utils import normalize_project_folder
21
22
 
22
23
  # Try to import adls_server modules
23
24
  try:
@@ -2747,7 +2748,7 @@ class OrcaOrchestrator:
2747
2748
  self.config_file = os.path.join(self.scenario_path, "orca_model_config.yaml")
2748
2749
  self.state_file = os.path.join(self.scenario_path, "orca_model_state.json")
2749
2750
  self.mode = mode
2750
- self.project_folder_override = project_folder
2751
+ self.project_folder_override = normalize_project_folder(project_folder)
2751
2752
 
2752
2753
  # Store model metadata dictionary for initialization
2753
2754
  self.metadata = metadata if metadata is not None else {}
@@ -0,0 +1,16 @@
1
+ """Helpers for handling ORCA project names / ADLS project folder paths."""
2
+
3
+
4
+ def normalize_project_folder(project_folder: str | None) -> str | None:
5
+ """Normalize a project folder path to the ADLS form (forward-slash separated).
6
+
7
+ Backslashes become forward slashes, empty segments (duplicate, leading and
8
+ trailing slashes) are dropped and whitespace around segments is stripped, so
9
+ that `proj\\sub\\run/` and `/proj//sub/run` both map to `proj/sub/run`.
10
+ Returns None when the input is None or contains no usable segment.
11
+ """
12
+ if project_folder is None:
13
+ return None
14
+ segments = [s.strip() for s in project_folder.replace("\\", "/").split("/")]
15
+ normalized = "/".join(s for s in segments if s and s not in (".", ".."))
16
+ return normalized or None
@@ -4737,7 +4737,7 @@ wheels = [
4737
4737
 
4738
4738
  [[package]]
4739
4739
  name = "tlpytools"
4740
- version = "0.2.13"
4740
+ version = "0.2.14"
4741
4741
  source = { editable = "." }
4742
4742
  dependencies = [
4743
4743
  { name = "azure-core" },
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