tobiko-cloud-helpers 202530.3.0__tar.gz → 202532.6.0__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 (19) hide show
  1. {tobiko_cloud_helpers-202530.3.0/tobiko_cloud_helpers.egg-info → tobiko_cloud_helpers-202532.6.0}/PKG-INFO +1 -1
  2. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/setup.py +1 -1
  3. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0/tobiko_cloud_helpers.egg-info}/PKG-INFO +1 -1
  4. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobiko_cloud_helpers.egg-info/SOURCES.txt +1 -0
  5. tobiko_cloud_helpers-202532.6.0/tobikodata/helpers/link.py +183 -0
  6. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/MANIFEST.in +0 -0
  7. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/backend_shim.py +0 -0
  8. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/setup.cfg +0 -0
  9. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobiko_cloud_helpers.egg-info/dependency_links.txt +0 -0
  10. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobiko_cloud_helpers.egg-info/namespace_packages.txt +0 -0
  11. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobiko_cloud_helpers.egg-info/top_level.txt +0 -0
  12. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/__init__.py +0 -0
  13. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/__init__.py +0 -0
  14. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/asyncio.py +0 -0
  15. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/compression.py +0 -0
  16. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/hashing.py +0 -0
  17. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/py.typed +0 -0
  18. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/secret_string.py +0 -0
  19. {tobiko_cloud_helpers-202530.3.0 → tobiko_cloud_helpers-202532.6.0}/tobikodata/helpers/tcloud_locations.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tobiko-cloud-helpers
3
- Version: 202530.3.0
3
+ Version: 202532.6.0
4
4
  Author: TobikoData Inc.
5
5
  Author-email: engineering@tobikodata.com
6
6
  Requires-Python: <3.13,>=3.9
@@ -22,5 +22,5 @@ setup(**{
22
22
  'tobikodata.helpers',
23
23
  ),
24
24
  'python_requires': '<3.13,>=3.9',
25
- 'version': '202530.3.0',
25
+ 'version': '202532.6.0',
26
26
  })
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tobiko-cloud-helpers
3
- Version: 202530.3.0
3
+ Version: 202532.6.0
4
4
  Author: TobikoData Inc.
5
5
  Author-email: engineering@tobikodata.com
6
6
  Requires-Python: <3.13,>=3.9
@@ -11,6 +11,7 @@ tobikodata/helpers/__init__.py
11
11
  tobikodata/helpers/asyncio.py
12
12
  tobikodata/helpers/compression.py
13
13
  tobikodata/helpers/hashing.py
14
+ tobikodata/helpers/link.py
14
15
  tobikodata/helpers/py.typed
15
16
  tobikodata/helpers/secret_string.py
16
17
  tobikodata/helpers/tcloud_locations.py
@@ -0,0 +1,183 @@
1
+ import enum
2
+ import typing as t
3
+ import urllib.parse
4
+ from dataclasses import dataclass
5
+
6
+ from tobikodata.helpers import urljoin
7
+
8
+
9
+ class ActionTab(str, enum.Enum):
10
+ SUMMARY = "summary"
11
+ EXPLORE = "explore"
12
+
13
+
14
+ class RunSummaryTab(str, enum.Enum):
15
+ EXECUTIONS = "executions"
16
+ AUDITS = "audits"
17
+
18
+
19
+ class PlanSummaryTab(str, enum.Enum):
20
+ DIFF_CHANGES = "diff-changes"
21
+ PHYSICAL_UPDATES = "physical-updates"
22
+ EXECUTIONS = "executions"
23
+ AUDITS = "audits"
24
+ VIRTUAL_UPDATES = "virtual-updates"
25
+
26
+
27
+ class DebuggerModelEvaluationTab(str, enum.Enum):
28
+ DEFINITION = "definition"
29
+ IMPACT = "impact"
30
+ SCHEMA = "schema"
31
+ INTERVALS = "intervals"
32
+
33
+
34
+ class DebuggerEvaluationTab(str, enum.Enum):
35
+ OVERVIEW = "overview"
36
+ ERROR = "error"
37
+ LOG = "log"
38
+
39
+
40
+ class TabName(str, enum.Enum):
41
+ TAB = "tab"
42
+ TAB_SUMMARY = "tab_summary"
43
+ TAB_MODEL_EVALUATION = "tab_model_evaluation"
44
+ TAB_EVALUATION = "tab_evaluation"
45
+ MODEL_NAME = "model_name"
46
+ EVALUATION_ID = "evaluation_id"
47
+
48
+
49
+ TabSummary = t.Union[RunSummaryTab, PlanSummaryTab]
50
+
51
+ EvaluationScope = t.Literal["plans", "runs"]
52
+ EnvironmentScope = t.Union[EvaluationScope, t.Literal["models"]]
53
+
54
+ # This is primarily for generating deep links for Plan or Run UI pages
55
+ # Used for Airflow / Dagster integrations, CICD bot, Plan links in the CLI
56
+
57
+
58
+ @dataclass
59
+ class TobikoCloudLinkGenerator:
60
+ environment: str
61
+ url_template: str = "/environments/{environment}/{scope}/{id}"
62
+ base: str = "/"
63
+
64
+ def get_environment_url(self) -> str:
65
+ return self._get_url(url_template="/environments/{environment}")
66
+
67
+ def get_model_details_url(self, model_name: str, model_version: str) -> str:
68
+ return self._get_url_with_query_params(
69
+ scope="models",
70
+ id=model_name,
71
+ query_params=urllib.parse.urlencode({"version": model_version}),
72
+ )
73
+
74
+ def get_plan_summary_url(self, plan_id: str) -> str:
75
+ return self._get_summary_url("plans", plan_id, PlanSummaryTab.DIFF_CHANGES)
76
+
77
+ def get_plan_audits_url(self, plan_id: str) -> str:
78
+ return self._get_summary_url("plans", plan_id, PlanSummaryTab.AUDITS)
79
+
80
+ def get_run_summary_url(self, run_id: str) -> str:
81
+ return self._get_summary_url(
82
+ scope="runs", plan_or_run_id=run_id, tab=RunSummaryTab.EXECUTIONS
83
+ )
84
+
85
+ def get_run_audits_url(self, run_id: str) -> str:
86
+ return self._get_summary_url(scope="runs", plan_or_run_id=run_id, tab=RunSummaryTab.AUDITS)
87
+
88
+ def get_plan_evaluation_overview_url(
89
+ self, plan_id: str, model_name: str, evaluation_id: str
90
+ ) -> str:
91
+ return self._get_evaluation_url(
92
+ "plans", plan_id, model_name, evaluation_id, DebuggerEvaluationTab.OVERVIEW
93
+ )
94
+
95
+ def get_plan_evaluation_log_url(self, plan_id: str, model_name: str, evaluation_id: str) -> str:
96
+ return self._get_evaluation_url(
97
+ "plans", plan_id, model_name, evaluation_id, DebuggerEvaluationTab.LOG
98
+ )
99
+
100
+ def get_run_evaluation_overview_url(
101
+ self, run_id: str, model_name: str, evaluation_id: str
102
+ ) -> str:
103
+ return self._get_evaluation_url(
104
+ "runs", run_id, model_name, evaluation_id, DebuggerEvaluationTab.OVERVIEW
105
+ )
106
+
107
+ def get_run_evaluation_log_url(self, run_id: str, model_name: str, evaluation_id: str) -> str:
108
+ return self._get_evaluation_url(
109
+ "runs", run_id, model_name, evaluation_id, DebuggerEvaluationTab.LOG
110
+ )
111
+
112
+ def _get_summary_url(
113
+ self,
114
+ scope: EvaluationScope,
115
+ plan_or_run_id: str,
116
+ tab: t.Union[PlanSummaryTab, RunSummaryTab],
117
+ ) -> str:
118
+ """Generate the URL for the summary with the search params (if any)"""
119
+ return self._get_url_with_query_params(
120
+ scope,
121
+ plan_or_run_id,
122
+ self._parse_query_params(
123
+ tab=ActionTab.SUMMARY,
124
+ tab_summary=tab,
125
+ ),
126
+ )
127
+
128
+ def _get_evaluation_url(
129
+ self,
130
+ scope: EvaluationScope,
131
+ plan_or_run_id: str,
132
+ model_name: str,
133
+ evaluation_id: str,
134
+ tab: DebuggerEvaluationTab,
135
+ ) -> str:
136
+ """Generate the URL for the evaluation log with the search params (if any)"""
137
+ return self._get_url_with_query_params(
138
+ scope,
139
+ plan_or_run_id,
140
+ self._parse_query_params(
141
+ tab=ActionTab.EXPLORE,
142
+ model_name=model_name,
143
+ evaluation_id=evaluation_id,
144
+ tab_model_evaluation=DebuggerModelEvaluationTab.DEFINITION,
145
+ tab_evaluation=tab,
146
+ ),
147
+ )
148
+
149
+ def _get_url(
150
+ self,
151
+ scope: t.Optional[EnvironmentScope] = None,
152
+ id: t.Optional[str] = None,
153
+ url_template: t.Optional[str] = None,
154
+ ) -> str:
155
+ """Generate the URL"""
156
+ url_template = url_template or self.url_template
157
+ return urljoin(
158
+ self.base,
159
+ url_template.format(
160
+ environment=self.environment,
161
+ scope=scope,
162
+ id=id,
163
+ ),
164
+ )
165
+
166
+ def _get_url_with_query_params(
167
+ self, scope: EnvironmentScope, id: str, query_params: str
168
+ ) -> str:
169
+ """Generate the URL with the search params (if any)"""
170
+ url = self._get_url(scope, id)
171
+ if query_params:
172
+ url += "?" + query_params
173
+ return url
174
+
175
+ def _parse_query_params(self, **kwargs: t.Any) -> str:
176
+ """Parse the search params from the kwargs"""
177
+ return urllib.parse.urlencode(
178
+ {
179
+ TabName(k).value: v.value if isinstance(v, enum.Enum) else v
180
+ for k, v in kwargs.items()
181
+ if v is not None
182
+ }
183
+ )