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
!65
Add create_elements function
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add create_elements function
add-create-elements
into
master
Overview
0
Commits
3
Pipelines
1
Changes
2
Merged
Eva Bardou
requested to merge
add-create-elements
into
master
4 years ago
Overview
0
Commits
3
Pipelines
1
Changes
2
Expand
Closes
#40 (closed)
Edited
4 years ago
by
Eva Bardou
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
563bb46a
3 commits,
4 years ago
2 files
+
343
−
0
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.py
+
59
−
0
Options
@@ -394,6 +394,65 @@ class ElementsWorker(BaseWorker):
return
sub_element
[
"
id
"
]
def
create_elements
(
self
,
parent
,
elements
):
"""
Create children elements on the given element through API
Return the IDs of created elements
"""
assert
parent
and
isinstance
(
parent
,
Element
),
"
element shouldn
'
t be null and should be of type Element
"
assert
elements
and
isinstance
(
elements
,
list
),
"
elements shouldn
'
t be null and should be of type list
"
for
index
,
element
in
enumerate
(
elements
):
assert
isinstance
(
element
,
dict
),
f
"
Element at index
{
index
}
in elements: Should be of type dict
"
name
=
element
.
get
(
"
name
"
)
assert
name
and
isinstance
(
name
,
str
),
f
"
Element at index
{
index
}
in elements: name shouldn
'
t be null and should be of type str
"
type
=
element
.
get
(
"
type
"
)
assert
type
and
isinstance
(
type
,
str
),
f
"
Element at index
{
index
}
in elements: type shouldn
'
t be null and should be of type str
"
polygon
=
element
.
get
(
"
polygon
"
)
assert
polygon
and
isinstance
(
polygon
,
list
),
f
"
Element at index
{
index
}
in elements: polygon shouldn
'
t be null and should be of type list
"
assert
(
len
(
polygon
)
>=
3
),
f
"
Element at index
{
index
}
in elements: polygon should have at least three points
"
assert
all
(
isinstance
(
point
,
list
)
and
len
(
point
)
==
2
for
point
in
polygon
),
f
"
Element at index
{
index
}
in elements: polygon points should be lists of two items
"
assert
all
(
isinstance
(
coord
,
(
int
,
float
))
for
point
in
polygon
for
coord
in
point
),
f
"
Element at index
{
index
}
in elements: polygon points should be lists of two numbers
"
if
self
.
is_read_only
:
logger
.
warning
(
"
Cannot create elements as this worker is in read-only mode
"
)
return
created_ids
=
self
.
api_client
.
request
(
"
CreateElements
"
,
id
=
parent
.
id
,
body
=
{
"
worker_version
"
:
self
.
worker_version_id
,
"
elements
"
:
elements
,
},
)
for
element
in
elements
:
self
.
report
.
add_element
(
parent
.
id
,
element
[
"
type
"
])
return
created_ids
def
create_transcription
(
self
,
element
,
text
,
type
=
None
,
score
=
None
):
"""
Create a transcription on the given element through the API.
Loading