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
Merge requests
!509
Fix 'create_classifications' helper
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Fix 'create_classifications' helper
fix-create-classifications
into
master
Overview
0
Commits
2
Pipelines
3
Changes
2
Merged
Manon Blanco
requested to merge
fix-create-classifications
into
master
1 year ago
Overview
0
Commits
2
Pipelines
3
Changes
2
Expand
Closes
#292 (closed)
0
0
Merge request reports
Compare
master
version 2
54964346
1 year ago
version 1
fb5b6fda
1 year ago
master (base)
and
latest version
latest version
16874613
2 commits,
1 year ago
version 2
54964346
1 commit,
1 year ago
version 1
fb5b6fda
4 commits,
1 year ago
2 files
+
152
−
155
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
arkindex_worker/worker/classification.py
+
18
−
18
Options
@@ -2,8 +2,6 @@
ElementsWorker methods for classifications and ML classes.
"""
from
uuid
import
UUID
from
apistar.exceptions
import
ErrorResponse
from
peewee
import
IntegrityError
@@ -178,10 +176,14 @@ class ClassificationMixin:
Create multiple classifications at once on the given element through the API.
:param element: The element to create classifications on.
:param classifications: The classifications to create, a list of dicts. Each of them contains
a **ml_class_id** (str), the ID of the MLClass for this classification;
a **confidence** (float), the confidence score, between 0 and 1;
a **high_confidence** (bool), the high confidence state of the classification.
:param classifications: A list of dicts representing a classification each, with the following keys:
ml_class (str)
Required. Name of the MLClass to use.
confidence (float)
Required. Confidence score for the classification. Must be between 0 and 1.
high_confidence (bool)
Optional. Whether or not the classification is of high confidence.
:returns: List of created classifications, as returned in the ``classifications`` field by
the ``CreateClassifications`` API endpoint.
@@ -194,18 +196,10 @@ class ClassificationMixin:
),
"
classifications shouldn
'
t be null and should be of type list
"
for
index
,
classification
in
enumerate
(
classifications
):
ml_class
_id
=
classification
.
get
(
"
ml_class
_id
"
)
ml_class
=
classification
.
get
(
"
ml_class
"
)
assert
(
ml_class_id
and
isinstance
(
ml_class_id
,
str
)
),
f
"
Classification at index
{
index
}
in classifications: ml_class_id shouldn
'
t be null and should be of type str
"
# Make sure it's a valid UUID
try
:
UUID
(
ml_class_id
)
except
ValueError
as
e
:
raise
ValueError
(
f
"
Classification at index
{
index
}
in classifications: ml_class_id is not a valid uuid.
"
)
from
e
ml_class
and
isinstance
(
ml_class
,
str
)
),
f
"
Classification at index
{
index
}
in classifications: ml_class shouldn
'
t be null and should be of type str
"
confidence
=
classification
.
get
(
"
confidence
"
)
assert
(
@@ -231,7 +225,13 @@ class ClassificationMixin:
body
=
{
"
parent
"
:
str
(
element
.
id
),
"
worker_run_id
"
:
self
.
worker_run_id
,
"
classifications
"
:
classifications
,
"
classifications
"
:
[
{
**
classification
,
"
ml_class
"
:
self
.
get_ml_class_id
(
classification
[
"
ml_class
"
]),
}
for
classification
in
classifications
],
},
)[
"
classifications
"
]
Loading