truefoundry 0.4.4rc2__py3-none-any.whl → 0.4.4rc3__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.
Potentially problematic release.
This version of truefoundry might be problematic. Click here for more details.
- truefoundry/deploy/python_deploy_codegen.py +75 -4
- {truefoundry-0.4.4rc2.dist-info → truefoundry-0.4.4rc3.dist-info}/METADATA +1 -1
- {truefoundry-0.4.4rc2.dist-info → truefoundry-0.4.4rc3.dist-info}/RECORD +5 -5
- {truefoundry-0.4.4rc2.dist-info → truefoundry-0.4.4rc3.dist-info}/WHEEL +0 -0
- {truefoundry-0.4.4rc2.dist-info → truefoundry-0.4.4rc3.dist-info}/entry_points.txt +0 -0
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import ast
|
|
2
2
|
import io
|
|
3
|
+
import json
|
|
3
4
|
import re
|
|
4
|
-
from typing import List
|
|
5
|
+
from typing import Dict, List, Optional
|
|
5
6
|
|
|
6
7
|
from rich.console import Console
|
|
7
8
|
from rich.pretty import pprint
|
|
8
9
|
|
|
9
|
-
from truefoundry.deploy import Application
|
|
10
|
+
from truefoundry.deploy import Application, LocalSource
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
def
|
|
13
|
+
def generate_deployment_code(
|
|
13
14
|
symbols_to_import: List[str],
|
|
14
15
|
application_type: str,
|
|
15
16
|
spec_repr: str,
|
|
@@ -108,6 +109,13 @@ def convert_deployment_config_to_python(workspace_fqn: str, application_spec: di
|
|
|
108
109
|
application = Application.parse_obj(application_spec)
|
|
109
110
|
application_type = application.__root__.type
|
|
110
111
|
|
|
112
|
+
if (
|
|
113
|
+
hasattr(application.__root__, "image")
|
|
114
|
+
and application.__root__.image.type == "build"
|
|
115
|
+
and application.__root__.image.build_source.type == "remote"
|
|
116
|
+
):
|
|
117
|
+
application.__root__.image.build_source = LocalSource(local_build=False)
|
|
118
|
+
|
|
111
119
|
spec_repr = get_python_repr(application.__root__)
|
|
112
120
|
spec_repr = replace_enums_with_values(spec_repr)
|
|
113
121
|
spec_repr = remove_none_type_fields(spec_repr)
|
|
@@ -120,7 +128,7 @@ def convert_deployment_config_to_python(workspace_fqn: str, application_spec: di
|
|
|
120
128
|
if "GitSource" in symbols_to_import:
|
|
121
129
|
symbols_to_import.append("LocalSource")
|
|
122
130
|
|
|
123
|
-
generated_code =
|
|
131
|
+
generated_code = generate_deployment_code(
|
|
124
132
|
symbols_to_import=symbols_to_import,
|
|
125
133
|
application_type=application_type,
|
|
126
134
|
spec_repr=spec_repr,
|
|
@@ -131,3 +139,66 @@ def convert_deployment_config_to_python(workspace_fqn: str, application_spec: di
|
|
|
131
139
|
generated_code = add_local_source_comment(generated_code)
|
|
132
140
|
|
|
133
141
|
return generated_code
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def generate_python_snippet_for_trigger_job(
|
|
145
|
+
application_fqn: str, command: Optional[str], params: Optional[Dict[str, str]]
|
|
146
|
+
):
|
|
147
|
+
job_run_python_template = """from truefoundry.deploy import trigger_job
|
|
148
|
+
|
|
149
|
+
response = trigger_job(
|
|
150
|
+
application_fqn="{{application_fqn}}",
|
|
151
|
+
# You can pass command or params, but not both
|
|
152
|
+
# command={{command}}
|
|
153
|
+
# params={{params}}
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
print(response.jobRunName)
|
|
157
|
+
"""
|
|
158
|
+
output_python_str = job_run_python_template.replace(
|
|
159
|
+
"{{application_fqn}}", application_fqn
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
if command is not None:
|
|
163
|
+
output_python_str = output_python_str.replace("{{command}}", repr(command))
|
|
164
|
+
output_python_str = output_python_str.replace("# command", "command")
|
|
165
|
+
else:
|
|
166
|
+
output_python_str = output_python_str.replace(
|
|
167
|
+
"{{command}}", "<Enter Command Here>"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
if params is not None:
|
|
171
|
+
output_python_str = output_python_str.replace("{{params}}", repr(params))
|
|
172
|
+
output_python_str = output_python_str.replace("# params", "params")
|
|
173
|
+
else:
|
|
174
|
+
output_python_str = output_python_str.replace(
|
|
175
|
+
"{{params}}", "<Enter Params(key-value pairs) here as python dict>"
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
return output_python_str
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def generate_curl_snippet_for_trigger_job(
|
|
182
|
+
control_plane_url: str,
|
|
183
|
+
application_id: str,
|
|
184
|
+
command: Optional[str],
|
|
185
|
+
params: Optional[Dict[str, str]],
|
|
186
|
+
):
|
|
187
|
+
job_run_curl_request_template = """curl -X 'POST' \\
|
|
188
|
+
'{{control_plane_url}}/api/svc/v1/jobs/trigger' \\
|
|
189
|
+
-H 'accept: */*' \\
|
|
190
|
+
-H 'Authorization: Bearer <Paste your API key here. You can generate it from the Settings Page>' \\
|
|
191
|
+
-H 'Content-Type: application/json' \\
|
|
192
|
+
-d '{
|
|
193
|
+
"applicationId": "{{application_id}}",
|
|
194
|
+
"input": {{input}}
|
|
195
|
+
}'
|
|
196
|
+
"""
|
|
197
|
+
output_curl_str = job_run_curl_request_template.replace(
|
|
198
|
+
"{{control_plane_url}}", control_plane_url
|
|
199
|
+
)
|
|
200
|
+
output_curl_str = output_curl_str.replace("{{application_id}}", application_id)
|
|
201
|
+
output_curl_str = output_curl_str.replace(
|
|
202
|
+
"{{input}}", json.dumps({"command": command, "params": params}, indent=2)
|
|
203
|
+
)
|
|
204
|
+
return output_curl_str
|
|
@@ -107,7 +107,7 @@ truefoundry/deploy/lib/model/entity.py,sha256=fq8hvdJQgQn4uZqxpKrzmaoJhQG53_EbDo
|
|
|
107
107
|
truefoundry/deploy/lib/session.py,sha256=Vg6rCA315T0yS0xG4ayJ84Ia_9ZfibH8utOSwPBMAmw,4953
|
|
108
108
|
truefoundry/deploy/lib/util.py,sha256=3TapV7yczkheC1MMMfmJDGGzTl2l6e4jCYd_Rr5aoQ8,1330
|
|
109
109
|
truefoundry/deploy/lib/win32.py,sha256=1RcvPTdlOAJ48rt8rCbE2Ufha2ztRqBAE9dueNXArrY,5009
|
|
110
|
-
truefoundry/deploy/python_deploy_codegen.py,sha256=
|
|
110
|
+
truefoundry/deploy/python_deploy_codegen.py,sha256=Fn2dgn_wcRigaR6Ia4pA7VdhWXaYl5D-o-K8P3953aA,6436
|
|
111
111
|
truefoundry/deploy/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
112
112
|
truefoundry/deploy/v2/lib/__init__.py,sha256=WEiVMZXOVljzEE3tpGJil14liIn_PCDoACJ6b3tZ6sI,188
|
|
113
113
|
truefoundry/deploy/v2/lib/deploy.py,sha256=HIcY3SzQ5lWl7avuuKi3J0Z-PBES6Sf4hgMK-m6_53U,11990
|
|
@@ -340,7 +340,7 @@ truefoundry/workflow/map_task.py,sha256=2m3qGXQ90k9LdS45q8dqCCECc3qr8t2m_LMCVd1m
|
|
|
340
340
|
truefoundry/workflow/python_task.py,sha256=SRXRLC4vdBqGjhkwuaY39LEWN6iPCpJAuW17URRdWTY,1128
|
|
341
341
|
truefoundry/workflow/task.py,sha256=ToitYiKcNzFCtOVQwz1W8sRjbR97eVS7vQBdbgUQtKg,1779
|
|
342
342
|
truefoundry/workflow/workflow.py,sha256=WaTqUjhwfAXDWu4E5ehuwAxrCbDJkoAf1oWmR2E9Qy0,4575
|
|
343
|
-
truefoundry-0.4.
|
|
344
|
-
truefoundry-0.4.
|
|
345
|
-
truefoundry-0.4.
|
|
346
|
-
truefoundry-0.4.
|
|
343
|
+
truefoundry-0.4.4rc3.dist-info/METADATA,sha256=C7iN6mFbrCfs3iLqyPq03a7Lu2QbqmiFwwiAc-G_qhc,3101
|
|
344
|
+
truefoundry-0.4.4rc3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
|
345
|
+
truefoundry-0.4.4rc3.dist-info/entry_points.txt,sha256=TXvUxQkI6zmqJuycPsyxEIMr3oqfDjgrWj0m_9X12x4,95
|
|
346
|
+
truefoundry-0.4.4rc3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|