Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Base Worker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Workers
Base Worker
Commits
9d498002
Commit
9d498002
authored
2 years ago
by
Yoann Schneider
Committed by
Bastien Abadie
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Do not erase defaults when reading configuration from worker
parent
a79848c3
No related branches found
Branches containing commit
Tags
0.3.2
Tags containing commit
1 merge request
!210
Do not erase defaults when reading configuration from worker
Pipeline
#79547
passed
2 years ago
Stage: test
Stage: build
Stage: release
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex_worker/worker/base.py
+7
-8
7 additions, 8 deletions
arkindex_worker/worker/base.py
tests/test_base_worker.py
+12
-3
12 additions, 3 deletions
tests/test_base_worker.py
with
19 additions
and
11 deletions
arkindex_worker/worker/base.py
+
7
−
8
View file @
9d498002
...
...
@@ -215,15 +215,14 @@ class BaseWorker(object):
# Load worker run configuration when available
worker_configuration
=
worker_run
.
get
(
"
configuration
"
)
self
.
user_configuration
=
(
worker_configuration
.
get
(
"
configuration
"
)
if
worker_configuration
else
None
)
if
self
.
user_configuration
:
if
worker_configuration
and
worker_configuration
.
get
(
"
configuration
"
):
logger
.
info
(
"
Loaded user configuration from WorkerRun
"
)
# if debug mode is set to true activate debug mode in logger
if
self
.
user_configuration
.
get
(
"
debug
"
):
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
debug
(
"
Debug output enabled
"
)
self
.
user_configuration
.
update
(
worker_configuration
.
get
(
"
configuration
"
))
# if debug mode is set to true activate debug mode in logger
if
self
.
user_configuration
.
get
(
"
debug
"
):
logger
.
setLevel
(
logging
.
DEBUG
)
logger
.
debug
(
"
Debug output enabled
"
)
def
configure_cache
(
self
):
task_id
=
os
.
environ
.
get
(
"
PONOS_TASK
"
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_base_worker.py
+
12
−
3
View file @
9d498002
...
...
@@ -249,7 +249,15 @@ def test_configure_user_configuration_defaults(
},
"
revision
"
:
{
"
hash
"
:
"
deadbeef1234
"
},
"
configuration
"
:
{
"
configuration
"
:
{
"
param_1
"
:
"
/some/path/file.pth
"
,
"
param_2
"
:
12
}
"
configuration
"
:
{
"
param_1
"
:
"
/some/path/file.pth
"
,
"
param_2
"
:
12
},
"
user_configuration
"
:
{
"
integer_parameter
"
:
{
"
type
"
:
"
int
"
,
"
title
"
:
"
Lambda
"
,
"
default
"
:
0
,
"
required
"
:
False
,
}
},
},
},
"
configuration
"
:
{
...
...
@@ -277,6 +285,7 @@ def test_configure_user_configuration_defaults(
assert
worker
.
config
==
{
"
param_1
"
:
"
/some/path/file.pth
"
,
"
param_2
"
:
12
}
assert
worker
.
user_configuration
==
{
"
integer_parameter
"
:
0
,
"
param_3
"
:
"
Animula vagula blandula
"
,
"
param_5
"
:
True
,
}
...
...
@@ -381,7 +390,7 @@ def test_configure_worker_run_missing_conf(mocker, monkeypatch, responses):
worker
.
args
=
worker
.
parser
.
parse_args
()
worker
.
configure
()
assert
worker
.
user_configuration
is
None
assert
worker
.
user_configuration
==
{}
def
test_configure_worker_run_no_worker_run_conf
(
mocker
,
monkeypatch
,
responses
):
...
...
@@ -431,7 +440,7 @@ def test_configure_worker_run_no_worker_run_conf(mocker, monkeypatch, responses)
worker
.
args
=
worker
.
parser
.
parse_args
()
worker
.
configure
()
assert
worker
.
user_configuration
is
None
assert
worker
.
user_configuration
==
{}
def
test_load_missing_secret
():
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment