thds.mops 3.6.20250409174111__py3-none-any.whl → 3.6.20250409195941__py3-none-any.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.
thds/mops/k8s/launch.py CHANGED
@@ -41,16 +41,27 @@ class Counter:
41
41
  return self.value
42
42
 
43
43
 
44
+ def sanitize_str(name: str) -> str:
45
+ # you can't have anything other than lowercase alphanumeric characters or dashes.
46
+ # you can't start with a dash. I don't know if you can end with a dash, but i see no point to that.
47
+ return "".join([c if c.isalnum() or c == "-" else "-" for c in name.lower()]).strip("-")
48
+
49
+
44
50
  def construct_job_name(user_prefix: str, job_num: str) -> str:
45
51
  # we want some consistency here, but also some randomness in case the prefixes don't exist or aren't unique.
46
- mops_name_part = "-".join([str(os.getpid()), job_num, str(uuid.uuid4())[:8]]).lstrip("-")
52
+ mops_name_part = "-".join([str(os.getpid()), sanitize_str(job_num), str(uuid.uuid4())[:8]])
47
53
  if len(mops_name_part) > 63:
48
54
  # this should be _impossible_, because having a job num longer than even 20 digits would be an impossibly large
49
55
  # number of jobs. but just in case, we'll truncate it to the last 63 characters.
50
56
  mops_name_part = mops_name_part[-63:] # keep the most random part, to avoid collisions
51
- name = f"{user_prefix[:63 - (len(mops_name_part) + 1)]}-{mops_name_part}"
52
- name = "".join([c if c.isalnum() or c == "-" else "-" for c in name.lower()])
53
- assert len(name) <= 63, f"Job name `{name}` is too long; max length is 63 characters."
57
+
58
+ user_prefix = sanitize_str(user_prefix)
59
+ if user_prefix:
60
+ name = f"{user_prefix[:63 - 1 - len(mops_name_part)]}-{mops_name_part}"
61
+ else:
62
+ name = mops_name_part
63
+ name = sanitize_str(name)
64
+ assert len(name) <= 63, f"Job name `{name}` is too long ({len(name)}); max length is 63 characters."
54
65
  return name
55
66
 
56
67
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: thds.mops
3
- Version: 3.6.20250409174111
3
+ Version: 3.6.20250409195941
4
4
  Summary: ML Ops tools for Trilliant Health
5
5
  Author-email: Trilliant Health <info@trillianthealth.com>
6
6
  Project-URL: Repository, https://github.com/TrilliantHealth/ds-monorepo
@@ -23,7 +23,7 @@ thds/mops/k8s/auth.py,sha256=mXFPZvyJYEPASsBatv1r8syB9AoayuHGptHHnNUg8LE,1517
23
23
  thds/mops/k8s/config.py,sha256=FyzuiUaNq8mQR01GqrezQWSc21QVqjLY9iaJUGu5WAo,2568
24
24
  thds/mops/k8s/container_registry.py,sha256=qOiGCE4t_tLYgJDGrhKV9KNv48lF_AlwCDHyFgucd2s,539
25
25
  thds/mops/k8s/jobs.py,sha256=3u0jc5Fnll2ncnmcdTUHlcxJ_KYNK9s66W7r6ez49As,3271
26
- thds/mops/k8s/launch.py,sha256=PXAcqFSLp839bKhu13RPFVH-UzOdS6u7hm_J-N5Kkeg,10087
26
+ thds/mops/k8s/launch.py,sha256=SIeao2oJVKEvef8vmWDoE8QAPIMBV2TmRxHYBRXaJFM,10479
27
27
  thds/mops/k8s/logging.py,sha256=yJ5Gt_luyo6LXbUJSXbhA4f1z7il1WuHQjMcP8eB00U,9591
28
28
  thds/mops/k8s/namespace.py,sha256=Z6trVTU9WFashto4PqIhTcxu-foOF93W0TpgqCU7WIA,383
29
29
  thds/mops/k8s/node_selection.py,sha256=Gy2Jz8IxZblg2LmtGg8-MtKI4RmXz2AMXqFPP8OQyu0,2065
@@ -103,8 +103,8 @@ thds/mops/pure/tools/summarize/cli.py,sha256=gaechsJhRZsOxGJGG1dQsW5dMBlgSv2sUmE
103
103
  thds/mops/pure/tools/summarize/run_summary.py,sha256=HCfAJhgAa9u6kXbzJlHa2n-9vVTaTHYSxrN_DP-Sjo4,4892
104
104
  thds/mops/testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
105
105
  thds/mops/testing/deferred_imports.py,sha256=f0ezCgQAtzTqW1yAOb0OWgsB9ZrlztLB894LtpWDaVw,3780
106
- thds_mops-3.6.20250409174111.dist-info/METADATA,sha256=V63NdIUiyQDBPAfHvu0ScVeTD6_h3TBmOotnGB9BdBM,2161
107
- thds_mops-3.6.20250409174111.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
108
- thds_mops-3.6.20250409174111.dist-info/entry_points.txt,sha256=GShNqjcjbq0TAJuwpyeCI5XCltiwdZxnNHkBpmYbNkU,329
109
- thds_mops-3.6.20250409174111.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
110
- thds_mops-3.6.20250409174111.dist-info/RECORD,,
106
+ thds_mops-3.6.20250409195941.dist-info/METADATA,sha256=kec_ctjKEDHeEP5JlZQvxfpRvxwrlFT7ru8FsmxAoMQ,2161
107
+ thds_mops-3.6.20250409195941.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
108
+ thds_mops-3.6.20250409195941.dist-info/entry_points.txt,sha256=GShNqjcjbq0TAJuwpyeCI5XCltiwdZxnNHkBpmYbNkU,329
109
+ thds_mops-3.6.20250409195941.dist-info/top_level.txt,sha256=LTZaE5SkWJwv9bwOlMbIhiS-JWQEEIcjVYnJrt-CriY,5
110
+ thds_mops-3.6.20250409195941.dist-info/RECORD,,