|
30 | 30 | "import syft as sy\n",
|
31 | 31 | "\n",
|
32 | 32 | "sy.requires(SYFT_VERSION)\n",
|
| 33 | + "\n", |
33 | 34 | "# syft absolute\n",
|
34 | 35 | "from syft.service.worker.image_registry import SyftImageRegistry\n",
|
35 |
| - "from syft.service.worker.worker_image import SyftWorkerImage\n", |
36 |
| - "\n", |
37 |
| - "sy.requires(SYFT_VERSION)" |
| 36 | + "from syft.service.worker.worker_image import SyftWorkerImage" |
38 | 37 | ]
|
39 | 38 | },
|
40 | 39 | {
|
|
486 | 485 | " # third party\n",
|
487 | 486 | " import requests\n",
|
488 | 487 | "\n",
|
489 |
| - " repos = requests.get(\"http://localhost:5678/v2/_catalog\").json()[\"repositories\"]\n", |
490 |
| - " tags = requests.get(\n", |
491 |
| - " \"http://localhost:5678/v2/openmined/custom-worker/tags/list\"\n", |
492 |
| - " ).json()[\"tags\"]\n", |
| 488 | + " base_url = f\"http://{workerimage.image_identifier.registry_host}\"\n", |
| 489 | + " expected_tag = workerimage.image_identifier.tag\n", |
| 490 | + "\n", |
| 491 | + " repos = requests.get(f\"{base_url}/v2/_catalog\").json()[\"repositories\"]\n", |
| 492 | + " tags = requests.get(f\"{base_url}/v2/openmined/custom-worker/tags/list\").json()\n", |
| 493 | + " tags = tags[\"tags\"]\n", |
493 | 494 | "\n",
|
494 | 495 | " assert (\n",
|
495 | 496 | " \"openmined/custom-worker\" in repos\n",
|
496 | 497 | " ), f\"'openmined/custom-worker' not uploaded to local registry | {repos}\"\n",
|
497 | 498 | " assert (\n",
|
498 |
| - " \"0.7.8\" in tags\n", |
499 |
| - " ), f\"'openmined/custom-worker' with tag '0.7.8' not available | {tags}\"" |
| 499 | + " expected_tag in tags\n", |
| 500 | + " ), f\"'openmined/custom-worker' with tag {expected_tag} not available | {tags}\"" |
500 | 501 | ]
|
501 | 502 | },
|
502 | 503 | {
|
|
739 | 740 | "metadata": {},
|
740 | 741 | "outputs": [],
|
741 | 742 | "source": [
|
742 |
| - "assert isinstance(worker_delete_res, sy.SyftSuccess)" |
| 743 | + "assert isinstance(worker_delete_res, sy.SyftSuccess), str(worker_delete_res)" |
743 | 744 | ]
|
744 | 745 | },
|
745 | 746 | {
|
|
981 | 982 | " res = domain_client.api.services.worker.delete(\n",
|
982 | 983 | " uid=worker.id,\n",
|
983 | 984 | " )\n",
|
984 |
| - " assert isinstance(res, sy.SyftSuccess)\n", |
| 985 | + " assert isinstance(res, sy.SyftSuccess), str(res)\n", |
985 | 986 | "\n",
|
986 | 987 | "# Adding some sleep to allow containers to be fully removed,\n",
|
987 | 988 | "# before removing the image\n",
|
|
1016 | 1017 | "outputs": [],
|
1017 | 1018 | "source": [
|
1018 | 1019 | "# Since the containers are delete, we should be able to delete the image\n",
|
1019 |
| - "assert isinstance(delete_res, sy.SyftSuccess)\n", |
| 1020 | + "assert isinstance(delete_res, sy.SyftSuccess), str(delete_res)\n", |
1020 | 1021 | "delete_res"
|
1021 | 1022 | ]
|
1022 | 1023 | },
|
|
1158 | 1159 | "metadata": {},
|
1159 | 1160 | "outputs": [],
|
1160 | 1161 | "source": [
|
1161 |
| - "assert isinstance(req_result, sy.SyftSuccess)" |
| 1162 | + "assert isinstance(req_result, sy.SyftSuccess), str(req_result)" |
1162 | 1163 | ]
|
1163 | 1164 | },
|
1164 | 1165 | {
|
|
1215 | 1216 | "metadata": {},
|
1216 | 1217 | "outputs": [],
|
1217 | 1218 | "source": [
|
1218 |
| - "test_build_res = docker_config_3.test_image_build(tag=docker_tag_3)\n", |
1219 |
| - "assert isinstance(test_build_res, sy.SyftSuccess)" |
| 1219 | + "# syft absolute\n", |
| 1220 | + "from syft.custom_worker.builder import CustomWorkerBuilder\n", |
| 1221 | + "from syft.service.response import SyftError\n", |
| 1222 | + "from syft.service.response import SyftSuccess\n", |
| 1223 | + "\n", |
| 1224 | + "\n", |
| 1225 | + "def test_image_build(config: str, tag: str, **kwargs):\n", |
| 1226 | + " builder = CustomWorkerBuilder()\n", |
| 1227 | + " try:\n", |
| 1228 | + " result = builder.build_image(\n", |
| 1229 | + " config=config, tag=tag, pull=True, rm=True, forcerm=True, **kwargs\n", |
| 1230 | + " )\n", |
| 1231 | + " return SyftSuccess(message=result.logs)\n", |
| 1232 | + " except Exception as e:\n", |
| 1233 | + " return SyftError(message=f\"Failed to build image !! Error: {str(e)}.\")\n", |
| 1234 | + "\n", |
| 1235 | + "\n", |
| 1236 | + "test_build_res = test_image_build(config=docker_config_3, tag=docker_tag_3)\n", |
| 1237 | + "assert isinstance(test_build_res, sy.SyftSuccess), str(test_build_res)" |
1220 | 1238 | ]
|
1221 | 1239 | },
|
1222 | 1240 | {
|
|
1270 | 1288 | "metadata": {},
|
1271 | 1289 | "outputs": [],
|
1272 | 1290 | "source": [
|
1273 |
| - "assert isinstance(req_result, sy.SyftSuccess)" |
| 1291 | + "assert isinstance(req_result, sy.SyftSuccess), str(req_result)" |
1274 | 1292 | ]
|
1275 | 1293 | },
|
1276 | 1294 | {
|
|
1343 | 1361 | " for worker in worker_pool.workers:\n",
|
1344 | 1362 | " res = domain_client.api.services.worker.delete(uid=worker.id, force=True)\n",
|
1345 | 1363 | " print(res)\n",
|
1346 |
| - " assert isinstance(res, sy.SyftSuccess)\n", |
| 1364 | + " assert isinstance(res, sy.SyftSuccess), str(res)\n", |
1347 | 1365 | "\n",
|
1348 | 1366 | "# Adding some sleep to allow containers to be fully removed,\n",
|
1349 | 1367 | "# before removing the image\n",
|
|
1388 | 1406 | "name": "python",
|
1389 | 1407 | "nbconvert_exporter": "python",
|
1390 | 1408 | "pygments_lexer": "ipython3",
|
1391 |
| - "version": "3.9.7" |
| 1409 | + "version": "3.11.2" |
1392 | 1410 | }
|
1393 | 1411 | },
|
1394 | 1412 | "nbformat": 4,
|
|
0 commit comments