Update main_app.py
Browse files- main_app.py +20 -2
main_app.py
CHANGED
@@ -216,6 +216,8 @@ def _(
|
|
216 |
task_credentials_details = setup_task_credentials(project_client)
|
217 |
elif deployment_client is not None:
|
218 |
task_credentials_details = setup_task_credentials(deployment_client)
|
|
|
|
|
219 |
elif project_client is not None and deployment_client is not None:
|
220 |
task_credentials_details = setup_task_credentials(project_client)
|
221 |
else:
|
@@ -228,7 +230,7 @@ def _(
|
|
228 |
task_credentials_details = None
|
229 |
client = None
|
230 |
|
231 |
-
return client, deployment_client, project_client
|
232 |
|
233 |
|
234 |
@app.cell
|
@@ -1720,7 +1722,7 @@ def _(client, mo, pd, upload_button, uuid):
|
|
1720 |
uuid_suffix = str(uuid.uuid4())[:4]
|
1721 |
|
1722 |
deployment_name = mo.ui.text(
|
1723 |
-
value=f"
|
1724 |
label="Deployment Name:",
|
1725 |
placeholder="<Must be completely unique>",
|
1726 |
)
|
@@ -1847,6 +1849,22 @@ def _(deploy_button, deployment_definition, mo):
|
|
1847 |
|
1848 |
return (deploy_fnc,)
|
1849 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1850 |
|
1851 |
@app.cell
|
1852 |
def _(client, mo, pd, sys):
|
|
|
216 |
task_credentials_details = setup_task_credentials(project_client)
|
217 |
elif deployment_client is not None:
|
218 |
task_credentials_details = setup_task_credentials(deployment_client)
|
219 |
+
elif client is not None:
|
220 |
+
task_credentials_details = setup_task_credentials(client)
|
221 |
elif project_client is not None and deployment_client is not None:
|
222 |
task_credentials_details = setup_task_credentials(project_client)
|
223 |
else:
|
|
|
230 |
task_credentials_details = None
|
231 |
client = None
|
232 |
|
233 |
+
return client, deployment_client, project_client, task_credentials_details
|
234 |
|
235 |
|
236 |
@app.cell
|
|
|
1722 |
uuid_suffix = str(uuid.uuid4())[:4]
|
1723 |
|
1724 |
deployment_name = mo.ui.text(
|
1725 |
+
value=f"{uploaded_function_name.value}_deployed_{uuid_suffix}",
|
1726 |
label="Deployment Name:",
|
1727 |
placeholder="<Must be completely unique>",
|
1728 |
)
|
|
|
1849 |
|
1850 |
return (deploy_fnc,)
|
1851 |
|
1852 |
+
@app.function
|
1853 |
+
def get_iam_token(api_key):
|
1854 |
+
import requests
|
1855 |
+
import certifi
|
1856 |
+
|
1857 |
+
return requests.post(
|
1858 |
+
"https://iam.cloud.ibm.com/identity/token",
|
1859 |
+
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
1860 |
+
data={
|
1861 |
+
"grant_type": "urn:ibm:params:oauth:grant-type:apikey",
|
1862 |
+
"apikey": api_key,
|
1863 |
+
},
|
1864 |
+
verify=certifi.where(),
|
1865 |
+
).json()["access_token"]
|
1866 |
+
|
1867 |
+
|
1868 |
|
1869 |
@app.cell
|
1870 |
def _(client, mo, pd, sys):
|