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
c0085e3b
Commit
c0085e3b
authored
4 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Patches
Plain Diff
Reload known ML classes when a 400 is received on creation
parent
74b734fb
No related branches found
No related tags found
No related merge requests found
Pipeline
#77996
passed
4 years ago
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex_worker/worker.py
+17
-4
17 additions, 4 deletions
arkindex_worker/worker.py
with
17 additions
and
4 deletions
arkindex_worker/worker.py
+
17
−
4
View file @
c0085e3b
...
...
@@ -8,6 +8,7 @@ import uuid
from
enum
import
Enum
from
pathlib
import
Path
import
apistar
import
gnupg
import
yaml
from
apistar.exceptions
import
ErrorResponse
...
...
@@ -294,11 +295,23 @@ class ElementsWorker(BaseWorker):
ml_class_id
=
self
.
classes
[
corpus_id
].
get
(
ml_class
)
if
ml_class_id
is
None
:
logger
.
info
(
f
"
Creating ML class
{
ml_class
}
on corpus
{
corpus_id
}
"
)
response
=
self
.
api_client
.
request
(
"
CreateMLClass
"
,
id
=
corpus_id
,
body
=
{
"
name
"
:
ml_class
}
)
try
:
response
=
self
.
api_client
.
request
(
"
CreateMLClass
"
,
id
=
corpus_id
,
body
=
{
"
name
"
:
ml_class
}
)
logger
.
debug
(
f
"
Created ML class
{
response
[
'
id
'
]
}
"
)
except
apistar
.
exceptions
.
ErrorResponse
as
e
:
# Only reload for 400 errors
if
e
.
status_code
!=
400
:
raise
# Reload and make sure we have the class
self
.
load_corpus_classes
(
corpus_id
)
assert
(
ml_class
in
self
.
classes
[
corpus_id
]
),
"
Missing class {ml_class} even after reloading
"
ml_class_id
=
self
.
classes
[
corpus_id
][
ml_class
]
=
response
[
"
id
"
]
logger
.
debug
(
f
"
Created ML class
{
ml_class_id
}
"
)
return
ml_class_id
...
...
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