poetry-plugin-ivcap 0.4.0__tar.gz → 0.4.2__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.
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/PKG-INFO +1 -1
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/poetry_plugin_ivcap/constants.py +3 -0
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/poetry_plugin_ivcap/docker.py +3 -1
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/poetry_plugin_ivcap/ivcap.py +21 -7
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/poetry_plugin_ivcap/plugin.py +3 -2
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/pyproject.toml +1 -1
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/AUTHORS.md +0 -0
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/LICENSE +0 -0
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/README.md +0 -0
- {poetry_plugin_ivcap-0.4.0 → poetry_plugin_ivcap-0.4.2}/poetry_plugin_ivcap/util.py +0 -0
|
@@ -19,6 +19,7 @@ DOCKER_BUILD_TEMPLATE_OPT = "docker-build-template"
|
|
|
19
19
|
|
|
20
20
|
DEF_POLICY = "urn:ivcap:policy:ivcap.base.metadata"
|
|
21
21
|
DEF_PORT = 8000
|
|
22
|
+
DEF_IVCAP_BASE_URL = "https://develop.ivcap.net"
|
|
22
23
|
|
|
23
24
|
DOCKER_BUILD_TEMPLATE = """
|
|
24
25
|
docker buildx build
|
|
@@ -33,6 +34,7 @@ docker buildx build
|
|
|
33
34
|
DOCKER_LAMBDA_RUN_TEMPLATE = """
|
|
34
35
|
docker run -it
|
|
35
36
|
-p #PORT#:#PORT#
|
|
37
|
+
-e IVCAP_BASE_URL=#IVCAP_BASE_URL#
|
|
36
38
|
--platform=linux/#ARCH#
|
|
37
39
|
--rm \
|
|
38
40
|
#NAME#_#ARCH#:#TAG#
|
|
@@ -40,6 +42,7 @@ DOCKER_LAMBDA_RUN_TEMPLATE = """
|
|
|
40
42
|
|
|
41
43
|
DOCKER_BATCH_RUN_TEMPLATE = """
|
|
42
44
|
docker run -it
|
|
45
|
+
-e IVCAP_BASE_URL=#IVCAP_BASE_URL#
|
|
43
46
|
--platform=linux/#ARCH#
|
|
44
47
|
-v #PROJECT_DIR#:/data
|
|
45
48
|
--rm \
|
|
@@ -12,7 +12,7 @@ from typing import Dict, List, Optional
|
|
|
12
12
|
from pydantic import BaseModel, Field
|
|
13
13
|
import subprocess
|
|
14
14
|
|
|
15
|
-
from .constants import DEF_PORT, DOCKER_BATCH_RUN_TEMPLATE, DOCKER_BUILD_TEMPLATE, DOCKER_BUILD_TEMPLATE_OPT, DOCKER_LAMBDA_RUN_TEMPLATE, DOCKER_RUN_OPT, DOCKER_RUN_TEMPLATE_OPT, PLUGIN_NAME, SERVICE_TYPE_OPT
|
|
15
|
+
from .constants import DEF_IVCAP_BASE_URL, DEF_PORT, DOCKER_BATCH_RUN_TEMPLATE, DOCKER_BUILD_TEMPLATE, DOCKER_BUILD_TEMPLATE_OPT, DOCKER_LAMBDA_RUN_TEMPLATE, DOCKER_RUN_OPT, DOCKER_RUN_TEMPLATE_OPT, PLUGIN_NAME, SERVICE_TYPE_OPT
|
|
16
16
|
from .util import command_exists, get_name, get_version
|
|
17
17
|
|
|
18
18
|
class DockerConfig(BaseModel):
|
|
@@ -66,8 +66,10 @@ class DockerConfig(BaseModel):
|
|
|
66
66
|
port_in_args = False
|
|
67
67
|
port = str(pdata.get("port", DEF_PORT))
|
|
68
68
|
|
|
69
|
+
base_url = os.environ.get("IVCAP_BASE_URL", DEF_IVCAP_BASE_URL)
|
|
69
70
|
t = template.strip()\
|
|
70
71
|
.replace("#DOCKER_NAME#", self.docker_name)\
|
|
72
|
+
.replace("#IVCAP_BASE_URL#", base_url)\
|
|
71
73
|
.replace("#NAME#", self.name)\
|
|
72
74
|
.replace("#TAG#", self.tag)\
|
|
73
75
|
.replace("#PORT#", port)\
|
|
@@ -13,7 +13,7 @@ import humanize
|
|
|
13
13
|
import subprocess
|
|
14
14
|
import requests
|
|
15
15
|
|
|
16
|
-
from .constants import DEF_POLICY, PLUGIN_NAME, POLICY_OPT, SERVICE_FILE_OPT, SERVICE_ID_OPT
|
|
16
|
+
from .constants import DEF_POLICY, PLUGIN_NAME, POLICY_OPT, SERVICE_FILE_OPT, SERVICE_ID_OPT, DEF_IVCAP_BASE_URL
|
|
17
17
|
|
|
18
18
|
from .docker import docker_cfg, docker_build, docker_push
|
|
19
19
|
from .util import command_exists, get_name, string_to_number
|
|
@@ -51,7 +51,9 @@ def service_register(data, line):
|
|
|
51
51
|
|
|
52
52
|
cmd = ["poetry", "run", "python", service, "--print-service-description"]
|
|
53
53
|
line(f"<debug>Running: {' '.join(cmd)} </debug>")
|
|
54
|
-
|
|
54
|
+
env = os.environ.copy()
|
|
55
|
+
env.setdefault("IVCAP_BASE_URL", DEF_IVCAP_BASE_URL)
|
|
56
|
+
svc = subprocess.check_output(cmd, env=env).decode()
|
|
55
57
|
|
|
56
58
|
svc = svc.replace("#DOCKER_IMG#", pkg.strip())\
|
|
57
59
|
.replace("#SERVICE_ID#", service_id)
|
|
@@ -87,7 +89,9 @@ def tool_register(data, line):
|
|
|
87
89
|
|
|
88
90
|
cmd = ["poetry", "run", "python", service, "--print-tool-description"]
|
|
89
91
|
line(f"<debug>Running: {' '.join(cmd)} </debug>")
|
|
90
|
-
|
|
92
|
+
env = os.environ.copy()
|
|
93
|
+
env.setdefault("IVCAP_BASE_URL", DEF_IVCAP_BASE_URL)
|
|
94
|
+
svc = subprocess.check_output(cmd, env=env).decode()
|
|
91
95
|
|
|
92
96
|
service_id = get_service_id(data, False, line)
|
|
93
97
|
svc = svc.replace("#SERVICE_ID#", service_id)
|
|
@@ -142,7 +146,7 @@ def exec_job(data, args, is_silent, line):
|
|
|
142
146
|
if not isinstance(args, list) or len(args) < 1:
|
|
143
147
|
raise Exception("args must be a list with at least one element")
|
|
144
148
|
file_name = args[0]
|
|
145
|
-
timeout =
|
|
149
|
+
timeout = 5 # default timeout
|
|
146
150
|
if len(args) == 1:
|
|
147
151
|
pass # only file_name provided
|
|
148
152
|
elif len(args) == 3 and args[1] == '--timeout':
|
|
@@ -212,7 +216,11 @@ def exec_job(data, args, is_silent, line):
|
|
|
212
216
|
if "application/json" in content_type:
|
|
213
217
|
try:
|
|
214
218
|
parsed = resp.json()
|
|
219
|
+
status = parsed.get("status")
|
|
220
|
+
if status and (not status in ["succeeded", "failed", "error"]):
|
|
221
|
+
return status
|
|
215
222
|
print(json.dumps(parsed, indent=2, sort_keys=True))
|
|
223
|
+
return None
|
|
216
224
|
except Exception as e:
|
|
217
225
|
line(f"<warning>Failed to parse JSON response: {e}</warning>")
|
|
218
226
|
line(f"<warning>Headers: {str(resp.headers)}</warning>")
|
|
@@ -221,6 +229,7 @@ def exec_job(data, args, is_silent, line):
|
|
|
221
229
|
else:
|
|
222
230
|
line(f"<warning>Received status code {resp.status_code}</warning>")
|
|
223
231
|
line(f"<warning>Headers: {str(resp.headers)}</warning>")
|
|
232
|
+
return "unknown"
|
|
224
233
|
|
|
225
234
|
if response.status_code == 202:
|
|
226
235
|
try:
|
|
@@ -229,7 +238,7 @@ def exec_job(data, args, is_silent, line):
|
|
|
229
238
|
# location = f"{payload.get('location')}/output"
|
|
230
239
|
location = f"{payload.get('location')}"
|
|
231
240
|
job_id = payload.get("job-id")
|
|
232
|
-
retry_later = payload.get("retry-later",
|
|
241
|
+
retry_later = payload.get("retry-later", 5)
|
|
233
242
|
if not is_silent:
|
|
234
243
|
line(f"<debug>Job '{job_id}' accepted, but no result yet. Polling in {retry_later} seconds.</debug>")
|
|
235
244
|
while True:
|
|
@@ -249,8 +258,13 @@ def exec_job(data, args, is_silent, line):
|
|
|
249
258
|
line(f"<error>Failed to parse polling response: {e}</error>")
|
|
250
259
|
break
|
|
251
260
|
else:
|
|
252
|
-
handle_response(poll_resp)
|
|
253
|
-
|
|
261
|
+
status = handle_response(poll_resp)
|
|
262
|
+
if status:
|
|
263
|
+
if not is_silent:
|
|
264
|
+
line(f"<debug>Status: '{status}'. Next poll in {retry_later} seconds.</debug>")
|
|
265
|
+
else:
|
|
266
|
+
break
|
|
267
|
+
|
|
254
268
|
except Exception as e:
|
|
255
269
|
line(f"<error>Failed to handle 202 response: {e}</error>")
|
|
256
270
|
else:
|
|
@@ -10,7 +10,7 @@ from cleo.helpers import argument, option
|
|
|
10
10
|
import subprocess
|
|
11
11
|
from importlib.metadata import version
|
|
12
12
|
|
|
13
|
-
from poetry_plugin_ivcap.constants import DOCKER_BUILD_TEMPLATE_OPT, DOCKER_RUN_TEMPLATE_OPT, PLUGIN_CMD, PLUGIN_NAME
|
|
13
|
+
from poetry_plugin_ivcap.constants import DEF_IVCAP_BASE_URL, DOCKER_BUILD_TEMPLATE_OPT, DOCKER_RUN_TEMPLATE_OPT, PLUGIN_CMD, PLUGIN_NAME
|
|
14
14
|
from poetry_plugin_ivcap.constants import PORT_OPT, SERVICE_FILE_OPT, SERVICE_ID_OPT, SERVICE_TYPE_OPT, POLICY_OPT
|
|
15
15
|
from poetry_plugin_ivcap.util import get_version
|
|
16
16
|
|
|
@@ -99,7 +99,7 @@ Configurable options in pyproject.toml:
|
|
|
99
99
|
elif sub == "service-register":
|
|
100
100
|
service_register(data, self.line)
|
|
101
101
|
elif sub == "create-service-id":
|
|
102
|
-
sid = create_service_id(data, self.line)
|
|
102
|
+
sid = create_service_id(data, is_silent, self.line)
|
|
103
103
|
print(sid)
|
|
104
104
|
elif sub == "get-service-id":
|
|
105
105
|
sid = get_service_id(data, is_silent, self.line)
|
|
@@ -127,6 +127,7 @@ Configurable options in pyproject.toml:
|
|
|
127
127
|
|
|
128
128
|
env = os.environ.copy()
|
|
129
129
|
env["VERSION"] = get_version(data, None, line)
|
|
130
|
+
env.setdefault("IVCAP_BASE_URL", DEF_IVCAP_BASE_URL)
|
|
130
131
|
|
|
131
132
|
cmd = ["poetry", "run", "python", service]
|
|
132
133
|
cmd.extend(args)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|