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
ac91877b
Commit
ac91877b
authored
2 years ago
by
Yoann Schneider
Committed by
Bastien Abadie
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Define api client in BaseWorker.__init__
parent
ec2c8462
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!187
Define api client in BaseWorker.__init__
Pipeline
#79371
passed
2 years ago
Stage: test
Stage: build
Stage: release
Stage: deploy
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
arkindex_worker/worker/__init__.py
+0
-2
0 additions, 2 deletions
arkindex_worker/worker/__init__.py
arkindex_worker/worker/base.py
+3
-0
3 additions, 0 deletions
arkindex_worker/worker/base.py
tests/test_base_worker.py
+0
-10
0 additions, 10 deletions
tests/test_base_worker.py
with
3 additions
and
12 deletions
arkindex_worker/worker/__init__.py
+
0
−
2
View file @
ac91877b
...
...
@@ -139,8 +139,6 @@ class ElementsWorker(
# CLI args are stored on the instance so that implementations can access them
self
.
args
=
self
.
parser
.
parse_args
()
super
().
setup_api_client
()
if
self
.
is_read_only
:
super
().
configure_for_developers
()
else
:
...
...
This diff is collapsed.
Click to expand it.
arkindex_worker/worker/base.py
+
3
−
0
View file @
ac91877b
...
...
@@ -125,6 +125,9 @@ class BaseWorker(object):
# is at least one available sqlite database either given or in the parent tasks
self
.
use_cache
=
False
# Define API Client
self
.
setup_api_client
()
@property
def
is_read_only
(
self
)
->
bool
:
"""
...
...
This diff is collapsed.
Click to expand it.
tests/test_base_worker.py
+
0
−
10
View file @
ac91877b
...
...
@@ -90,7 +90,6 @@ def test_init_var_worker_local_file(monkeypatch, tmp_path):
def
test_cli_default
(
mocker
,
mock_worker_run_api
):
worker
=
BaseWorker
()
assert
logger
.
level
==
logging
.
NOTSET
assert
not
hasattr
(
worker
,
"
api_client
"
)
mocker
.
patch
.
object
(
sys
,
"
argv
"
,
[
"
worker
"
])
worker
.
args
=
worker
.
parser
.
parse_args
()
...
...
@@ -98,7 +97,6 @@ def test_cli_default(mocker, mock_worker_run_api):
assert
worker
.
worker_version_id
==
"
12341234-1234-1234-1234-123412341234
"
assert
worker
.
worker_run_id
==
"
56785678-5678-5678-5678-567856785678
"
worker
.
setup_api_client
()
worker
.
configure
()
assert
not
worker
.
args
.
verbose
assert
logger
.
level
==
logging
.
NOTSET
...
...
@@ -111,7 +109,6 @@ def test_cli_default(mocker, mock_worker_run_api):
def
test_cli_arg_verbose_given
(
mocker
,
mock_worker_run_api
):
worker
=
BaseWorker
()
assert
logger
.
level
==
logging
.
NOTSET
assert
not
hasattr
(
worker
,
"
api_client
"
)
mocker
.
patch
.
object
(
sys
,
"
argv
"
,
[
"
worker
"
,
"
-v
"
])
worker
.
args
=
worker
.
parser
.
parse_args
()
...
...
@@ -119,7 +116,6 @@ def test_cli_arg_verbose_given(mocker, mock_worker_run_api):
assert
worker
.
worker_version_id
==
"
12341234-1234-1234-1234-123412341234
"
assert
worker
.
worker_run_id
==
"
56785678-5678-5678-5678-567856785678
"
worker
.
setup_api_client
()
worker
.
configure
()
assert
worker
.
args
.
verbose
assert
logger
.
level
==
logging
.
DEBUG
...
...
@@ -133,7 +129,6 @@ def test_cli_envvar_debug_given(mocker, monkeypatch, mock_worker_run_api):
worker
=
BaseWorker
()
assert
logger
.
level
==
logging
.
NOTSET
assert
not
hasattr
(
worker
,
"
api_client
"
)
mocker
.
patch
.
object
(
sys
,
"
argv
"
,
[
"
worker
"
])
monkeypatch
.
setenv
(
"
ARKINDEX_DEBUG
"
,
True
)
worker
.
args
=
worker
.
parser
.
parse_args
()
...
...
@@ -141,7 +136,6 @@ def test_cli_envvar_debug_given(mocker, monkeypatch, mock_worker_run_api):
assert
worker
.
worker_version_id
==
"
12341234-1234-1234-1234-123412341234
"
assert
worker
.
worker_run_id
==
"
56785678-5678-5678-5678-567856785678
"
worker
.
setup_api_client
()
worker
.
configure
()
assert
logger
.
level
==
logging
.
DEBUG
assert
worker
.
api_client
...
...
@@ -215,7 +209,6 @@ def test_configure_worker_run(mocker, monkeypatch, responses):
assert
worker
.
worker_version_id
==
"
12341234-1234-1234-1234-123412341234
"
assert
worker
.
worker_run_id
==
"
56785678-5678-5678-5678-567856785678
"
worker
.
setup_api_client
()
worker
.
configure
()
assert
worker
.
user_configuration
==
{
"
a
"
:
"
b
"
}
...
...
@@ -274,7 +267,6 @@ def test_configure_user_configuration_defaults(
content_type
=
"
application/json
"
,
)
worker
.
setup_api_client
()
worker
.
configure
()
assert
worker
.
config
==
{
"
param_1
"
:
"
/some/path/file.pth
"
,
"
param_2
"
:
12
}
...
...
@@ -328,7 +320,6 @@ def test_configure_user_config_debug(mocker, monkeypatch, responses, debug):
content_type
=
"
application/json
"
,
)
worker
.
args
=
worker
.
parser
.
parse_args
()
worker
.
setup_api_client
()
worker
.
configure
()
assert
worker
.
user_configuration
==
{
"
debug
"
:
debug
}
...
...
@@ -376,7 +367,6 @@ def test_configure_worker_run_missing_conf(mocker, monkeypatch, responses):
content_type
=
"
application/json
"
,
)
worker
.
args
=
worker
.
parser
.
parse_args
()
worker
.
setup_api_client
()
worker
.
configure
()
assert
worker
.
user_configuration
is
None
...
...
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