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
5781d885
Commit
5781d885
authored
2 years ago
by
Yoann Schneider
Committed by
Bastien Abadie
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use pathlib.path for work_dir
parent
06520aed
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!314
Use pathlib.path for work_dir
Pipeline
#80154
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
+1
-1
1 addition, 1 deletion
arkindex_worker/worker/__init__.py
arkindex_worker/worker/base.py
+4
-4
4 additions, 4 deletions
arkindex_worker/worker/base.py
tests/test_base_worker.py
+4
-4
4 additions, 4 deletions
tests/test_base_worker.py
with
9 additions
and
9 deletions
arkindex_worker/worker/__init__.py
+
1
−
1
View file @
5781d885
...
...
@@ -235,7 +235,7 @@ class ElementsWorker(
self
.
report
.
error
(
element_id
,
e
)
# Save report as local artifact
self
.
report
.
save
(
os
.
path
.
join
(
self
.
work_dir
,
"
ml_report.json
"
)
)
self
.
report
.
save
(
self
.
work_dir
/
"
ml_report.json
"
)
if
failed
:
logger
.
error
(
...
...
This diff is collapsed.
Click to expand it.
arkindex_worker/worker/base.py
+
4
−
4
View file @
5781d885
...
...
@@ -112,15 +112,15 @@ class BaseWorker(object):
# Setup workdir either in Ponos environment or on host's home
if
os
.
environ
.
get
(
"
PONOS_DATA
"
):
self
.
work_dir
=
os
.
path
.
join
(
os
.
environ
[
"
PONOS_DATA
"
],
"
current
"
)
self
.
work_dir
=
Path
(
os
.
environ
[
"
PONOS_DATA
"
],
"
current
"
)
else
:
# We use the official XDG convention to store file for developers
# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
xdg_data_home
=
os
.
environ
.
get
(
"
XDG_DATA_HOME
"
,
os
.
path
.
expanduser
(
"
~/.local/share
"
)
)
self
.
work_dir
=
os
.
path
.
join
(
xdg_data_home
,
"
arkindex
"
)
os
.
makedirs
(
self
.
work_dir
,
exist_ok
=
True
)
self
.
work_dir
=
Path
(
xdg_data_home
,
"
arkindex
"
)
self
.
work_dir
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
# Store task ID. This is only available when running in production
# through a ponos agent
...
...
@@ -377,7 +377,7 @@ class BaseWorker(object):
if
self
.
task_id
:
# When running in production with ponos, the agent
# downloads the model and set it in the current task work dir
return
Path
(
self
.
work_dir
)
return
self
.
work_dir
else
:
model_dir
=
self
.
config
.
get
(
"
model_dir
"
,
self
.
args
.
model_dir
)
if
model_dir
is
None
:
...
...
This diff is collapsed.
Click to expand it.
tests/test_base_worker.py
+
4
−
4
View file @
5781d885
...
...
@@ -17,7 +17,7 @@ from arkindex_worker.worker.base import ModelNotFoundError
def
test_init_default_local_share
(
monkeypatch
):
worker
=
BaseWorker
()
assert
worker
.
work_dir
==
os
.
path
.
expanduser
(
"
~/.local/share/arkindex
"
)
assert
str
(
worker
.
work_dir
)
==
os
.
path
.
expanduser
(
"
~/.local/share/arkindex
"
)
def
test_init_default_xdg_data_home
(
monkeypatch
):
...
...
@@ -25,13 +25,13 @@ def test_init_default_xdg_data_home(monkeypatch):
monkeypatch
.
setenv
(
"
XDG_DATA_HOME
"
,
path
)
worker
=
BaseWorker
()
assert
worker
.
work_dir
==
f
"
{
path
}
/arkindex
"
assert
str
(
worker
.
work_dir
)
==
f
"
{
path
}
/arkindex
"
def
test_init_with_local_cache
(
monkeypatch
):
worker
=
BaseWorker
(
support_cache
=
True
)
assert
worker
.
work_dir
==
os
.
path
.
expanduser
(
"
~/.local/share/arkindex
"
)
assert
str
(
worker
.
work_dir
)
==
os
.
path
.
expanduser
(
"
~/.local/share/arkindex
"
)
assert
worker
.
support_cache
is
True
...
...
@@ -40,7 +40,7 @@ def test_init_var_ponos_data_given(monkeypatch):
monkeypatch
.
setenv
(
"
PONOS_DATA
"
,
path
)
worker
=
BaseWorker
()
assert
worker
.
work_dir
==
f
"
{
path
}
/current
"
assert
str
(
worker
.
work_dir
)
==
f
"
{
path
}
/current
"
def
test_init_var_worker_run_id_missing
(
monkeypatch
):
...
...
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