Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LinkAhead Sample Management
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue 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
caosdb
Software
LinkAhead Sample Management
Commits
b9c1ea00
Commit
b9c1ea00
authored
2 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
MAINT: Remove debugging output
parent
7ff39fa3
No related branches found
No related tags found
1 merge request
!1
F awi sams
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sample-management-custom/caosdb-server/scripting/bin/register_new_containers.py
+26
-27
26 additions, 27 deletions
...om/caosdb-server/scripting/bin/register_new_containers.py
with
26 additions
and
27 deletions
sample-management-custom/caosdb-server/scripting/bin/register_new_containers.py
+
26
−
27
View file @
b9c1ea00
...
...
@@ -126,7 +126,6 @@ def create_container_entities(responsible_id, container_type_id, container_size,
# Post process child containers
batch
=
post_process_containers
(
batch
)
try
:
logger
.
info
(
batch
)
batch
.
insert
()
except
Exception
as
e
:
logger
.
error
(
"
{} The registered containers could not be imported to the system. {}
"
.
format
(
...
...
@@ -138,7 +137,7 @@ def create_container_entities(responsible_id, container_type_id, container_size,
# Add to parent container
if
parent_container
is
not
None
:
child_cont_prop
=
db
.
Property
(
name
=
get_entity_name
(
"
child_container_prop
"
)).
retrieve
()
new_childs
=
[]
new_childs
=
[]
for
entity
in
batch
:
new_childs
+=
[
entity
.
id
]
# Check if property Child container exists:
...
...
@@ -147,10 +146,10 @@ def create_container_entities(responsible_id, container_type_id, container_size,
else
:
# Check if the container allready has childs
if
parent_container
.
get_property
(
child_cont_prop
.
name
).
value
is
None
:
parent_container
.
get_property
(
child_cont_prop
.
name
).
value
=
new_childs
parent_container
.
get_property
(
child_cont_prop
.
name
).
value
=
new_childs
else
:
parent_container
.
get_property
(
child_cont_prop
.
name
).
value
+=
new_childs
parent_container
=
post_process_parent_container
(
parent_container
)
parent_container
=
post_process_parent_container
(
parent_container
)
parent_container
.
update
()
set_label_counter
(
container_type_id
=
container_type_id
,
...
...
@@ -159,14 +158,14 @@ def create_container_entities(responsible_id, container_type_id, container_size,
def
get_template_name
(
container_entities
,
file_format_extension
):
first_id
=
container_entities
[
0
].
id
last_id
=
container_entities
[
-
1
].
id
first_id
=
container_entities
[
0
].
id
last_id
=
container_entities
[
-
1
].
id
return
"
container_template_(IDs_{}_to_{}).{}
"
.
format
(
first_id
,
last_id
,
file_format_extension
)
def
get_parent_container
(
id
):
try
:
parent
=
db
.
execute_query
(
"
FIND {}
"
.
format
(
id
))[
0
]
parent
=
db
.
execute_query
(
"
FIND {}
"
.
format
(
id
))[
0
]
return
parent
except
:
logger
.
info
(
...
...
@@ -178,7 +177,7 @@ def get_parent_container(id):
def
get_container_type
(
id
):
try
:
type
=
db
.
execute_query
(
"
FIND {}
"
.
format
(
id
))[
0
]
type
=
db
.
execute_query
(
"
FIND {}
"
.
format
(
id
))[
0
]
return
type
except
:
logger
.
error
(
"
{}The specified ContainerType could not be retrieved. {}
"
.
format
(
...
...
@@ -187,13 +186,13 @@ def get_container_type(id):
def
create_csv_template
(
template_internal_path
,
container_entities
,
container_type
,
container_size
,
parent_container
):
if
parent_container
is
None
:
parent_container_label
=
""
parent_container_label
=
""
else
:
parent_container_label
=
get_container_identifier
(
parent_container
)
parent_container_label
=
get_container_identifier
(
parent_container
)
with
open
(
template_internal_path
,
'
w
'
)
as
template_csv
:
writer
=
csv
.
writer
(
template_csv
)
writer
=
csv
.
writer
(
template_csv
)
# Write header
headers
=
[
headers
=
[
"
entity_id
"
,
"
container_type_rt
"
,
"
container_size_prop
"
,
...
...
@@ -205,13 +204,13 @@ def create_csv_template(template_internal_path, container_entities, container_ty
"
Container Contents
"
,
"
PDFReport
"
]
headers
=
[
get_column_header_name
(
header
)
for
header
in
headers
]
headers
=
[
get_column_header_name
(
header
)
for
header
in
headers
]
writer
.
writerow
(
headers
)
# Write description with leading '#'
descriptions
=
get_description_row
(
headers
)
descriptions
=
get_description_row
(
headers
)
if
descriptions
:
writer
.
writerow
(
descriptions
)
options
=
get_options_row
(
headers
)
options
=
get_options_row
(
headers
)
if
options
:
writer
.
writerow
(
options
)
# Write entity data to the lines
...
...
@@ -229,34 +228,34 @@ def create_csv_template(template_internal_path, container_entities, container_ty
def
main
():
parser
=
get_parser
()
args
=
parser
.
parse_args
()
parser
=
get_parser
()
args
=
parser
.
parse_args
()
global
logger
# Check whether executed locally or as an SSS depending on
# auth_token argument.
if
hasattr
(
args
,
"
auth_token
"
)
and
args
.
auth_token
:
db
.
configure_connection
(
auth_token
=
args
.
auth_token
)
debug_file
=
configure_server_side_logging
()
debug_file
=
configure_server_side_logging
()
# logger = logging.getLogger("caosadvancedtools")
else
:
# logging config for local execution
# logger = logging.getLogger("caosadvancedtools")
logger
.
addHandler
(
logging
.
StreamHandler
(
sys
.
stdout
))
logger
.
setLevel
(
logging
.
DEBUG
)
debug_file
=
None
debug_file
=
None
if
hasattr
(
args
,
"
filename
"
)
and
args
.
filename
:
# Read the input from the form (form.json)
with
open
(
args
.
filename
)
as
form_json
:
form_data
=
json
.
load
(
form_json
)
form_data
=
json
.
load
(
form_json
)
parent_container
=
get_parent_container
(
form_data
[
"
parent_id
"
])
container_type
=
get_container_type
(
form_data
[
"
container_type
"
])
container_size
=
form_data
[
"
container_size
"
]
parent_container
=
get_parent_container
(
form_data
[
"
parent_id
"
])
container_type
=
get_container_type
(
form_data
[
"
container_type
"
])
container_size
=
form_data
[
"
container_size
"
]
# Create entities in BIS
container_entities
=
create_container_entities
(
container_entities
=
create_container_entities
(
responsible_id
=
int
(
form_data
[
"
responsible_entity
"
]),
container_type_id
=
int
(
form_data
[
"
container_type
"
]),
container_size
=
container_size
,
...
...
@@ -270,9 +269,9 @@ def main():
return
1
# Create template file on the server
file_format_extension
=
form_data
[
"
file_format
"
]
template_name
=
get_template_name
(
container_entities
,
file_format_extension
)
template_display_path
,
template_internal_path
=
helper
.
get_shared_filename
(
file_format_extension
=
form_data
[
"
file_format
"
]
template_name
=
get_template_name
(
container_entities
,
file_format_extension
)
template_display_path
,
template_internal_path
=
helper
.
get_shared_filename
(
template_name
)
if
(
file_format_extension
==
"
csv
"
):
create_csv_template
(
...
...
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