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
22d871ef
Commit
22d871ef
authored
4 years ago
by
Eva Bardou
Committed by
Bastien Abadie
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add generic function create_sub_element()
parent
fbb412bd
No related branches found
Branches containing commit
Tags
0.1.9
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arkindex_worker/worker.py
+36
-0
36 additions, 0 deletions
arkindex_worker/worker.py
with
36 additions
and
0 deletions
arkindex_worker/worker.py
+
36
−
0
View file @
22d871ef
...
...
@@ -148,3 +148,39 @@ class ElementsWorker(BaseWorker):
def
process_element
(
self
,
element
):
"""
Override this method to analyze an Arkindex element from the provided list
"""
def
create_sub_element
(
self
,
element
,
type
,
name
,
polygon
):
"""
Create a child element on the given element through API
"""
assert
element
and
isinstance
(
element
,
Element
),
"
element shouldn
'
t be null and should be of type Element
"
assert
type
and
isinstance
(
type
,
str
),
"
type shouldn
'
t be null and should be of type str
"
assert
name
and
isinstance
(
name
,
str
),
"
name shouldn
'
t be null and should be of type str
"
assert
polygon
and
isinstance
(
polygon
,
list
),
"
polygon shouldn
'
t be null and should be of type list
"
assert
len
(
polygon
)
>=
3
,
"
polygon should have at least three points
"
assert
all
(
isinstance
(
point
,
list
)
and
len
(
point
)
==
2
for
point
in
polygon
),
"
polygon points should be lists of two items
"
assert
all
(
isinstance
(
coord
,
(
int
,
float
))
for
point
in
polygon
for
coord
in
point
),
"
polygon points should be lists of two numbers
"
self
.
api_client
.
request
(
"
CreateElement
"
,
body
=
{
"
type
"
:
type
,
"
name
"
:
name
,
"
image
"
:
element
.
zone
.
image
.
id
,
"
corpus
"
:
element
.
corpus
.
id
,
"
polygon
"
:
polygon
,
"
parent
"
:
element
.
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