Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • workers/base-worker
1 result
Show changes
Commits on Source (5)
0.3.0-rc2
0.3.0-rc5
......@@ -196,7 +196,7 @@ class BaseWorker(object):
)
# Retrieve initial configuration from API
self.config = worker_version["configuration"]["configuration"]
self.config = worker_version["configuration"].get("configuration")
if "user_configuration" in worker_version["configuration"]:
# Add default values (if set) to user_configuration
for key, value in worker_version["configuration"][
......@@ -211,7 +211,9 @@ class BaseWorker(object):
# Load worker run configuration when available
worker_configuration = worker_run.get("configuration")
self.user_configuration = worker_configuration.get("configuration")
self.user_configuration = (
worker_configuration.get("configuration") if worker_configuration else None
)
if self.user_configuration:
logger.info("Loaded user configuration from WorkerRun")
# if debug mode is set to true activate debug mode in logger
......
......@@ -167,8 +167,8 @@ class TrainingMixin(object):
def update_model_version(
self,
model_version_details: dict,
description: str = None,
configuration: dict = None,
description: str = "",
configuration: dict = {},
tag: str = None,
) -> None:
"""
......
......@@ -372,6 +372,53 @@ def test_configure_worker_run_missing_conf(mocker, monkeypatch, responses):
assert worker.user_configuration is None
def test_configure_worker_run_no_worker_run_conf(mocker, monkeypatch, responses):
"""
No configuration is provided but should not crash
"""
worker = BaseWorker()
mocker.patch.object(sys, "argv", ["worker"])
payload = {
"id": "56785678-5678-5678-5678-567856785678",
"parents": [],
"worker_version_id": "12341234-1234-1234-1234-123412341234",
"model_version_id": None,
"dataimport_id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff",
"worker": {
"id": "deadbeef-1234-5678-1234-worker",
"name": "Fake worker",
"slug": "fake_worker",
"type": "classifier",
},
"configuration_id": None,
"worker_version": {
"id": "12341234-1234-1234-1234-123412341234",
"worker": {
"id": "deadbeef-1234-5678-1234-worker",
"name": "Fake worker",
"slug": "fake_worker",
"type": "classifier",
},
"revision": {"hash": "deadbeef1234"},
"configuration": {},
},
"configuration": None,
"process": {"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeffff"},
}
responses.add(
responses.GET,
"http://testserver/api/v1/imports/workers/56785678-5678-5678-5678-567856785678/",
status=200,
body=json.dumps(payload),
content_type="application/json",
)
worker.args = worker.parser.parse_args()
worker.configure()
assert worker.user_configuration is None
def test_load_missing_secret():
worker = BaseWorker()
worker.api_client = MockApiClient()
......