Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
quiver-mongoapi-local
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
subugoe
OCR-D
quiver-mongoapi-local
Commits
f9bfd29b
Commit
f9bfd29b
authored
5 months ago
by
Michelle Weidling
Browse files
Options
Downloads
Patches
Plain Diff
first draft for not considering CPU
parent
cf76e763
No related branches found
No related tags found
No related merge requests found
Pipeline
#508907
passed
5 months ago
Stage: test
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/commons.py
+10
-0
10 additions, 0 deletions
src/commons.py
src/runs.py
+12
-5
12 additions, 5 deletions
src/runs.py
with
22 additions
and
5 deletions
src/commons.py
+
10
−
0
View file @
f9bfd29b
...
...
@@ -16,3 +16,13 @@ def remove_mongodb_id_from_result(json_data, result_type) -> list:
d
=
d
[
'
gt_workspace
'
]
purged_list
.
append
(
d
)
return
purged_list
def
remove_key_from_dict
(
d
:
dict
,
tbr_key
:
str
)
->
None
:
"""
This function removes keys with the value of null from the result.
"""
for
key
in
list
(
d
.
keys
()):
if
key
==
tbr_key
and
d
[
key
]
==
None
:
del
d
[
key
]
else
:
remove_key_from_dict
(
d
[
key
],
tbr_key
)
This diff is collapsed.
Click to expand it.
src/runs.py
+
12
−
5
View file @
f9bfd29b
...
...
@@ -8,7 +8,7 @@ from re import compile, Pattern
from
bson
import
json_util
from
pymongo
import
collection
from
model
import
Model
from
commons
import
remove_mongodb_id_from_result
from
commons
import
remove_mongodb_id_from_result
,
remove_key_from_dict
from
gt
import
get_all_gt
from
workflows
import
get_all_workflows
...
...
@@ -20,8 +20,9 @@ def get_all_runs(coll: collection.Collection):
"""
cursor
=
coll
.
find
({
'
eval_workflow_id
'
:
{
'
$exists
'
:
True
}})
json_data
=
json
.
loads
(
json_util
.
dumps
(
cursor
))
purged
=
remove_key_from_dict
(
json_data
,
'
cpu
'
)
return
remove_mongodb_id_from_result
(
json_data
,
'
run
'
)
return
remove_mongodb_id_from_result
(
purged
,
'
run
'
)
def
get_all_latest_runs
(
coll
:
collection
.
Collection
):
"""
...
...
@@ -71,7 +72,9 @@ def get_all_runs_by_gt(coll: collection.Collection,
cursor
=
coll
.
find
({
'
metadata.gt_workspace.id
'
:
gt_regex
})
json_data
=
json
.
loads
(
json_util
.
dumps
(
cursor
))
return
remove_mongodb_id_from_result
(
json_data
,
'
run
'
)
purged
=
remove_key_from_dict
(
json_data
,
'
cpu
'
)
return
remove_mongodb_id_from_result
(
purged
,
'
run
'
)
def
get_all_runs_by_gt_and_wf
(
coll
:
collection
.
Collection
,
...
...
@@ -95,7 +98,9 @@ def get_all_runs_by_gt_and_wf(coll: collection.Collection,
cursor
=
coll
.
find
({
'
$and
'
:
[{
'
metadata.gt_workspace.id
'
:
gt_regex
},
{
'
metadata.ocr_workflow.id
'
:
wf_regex
}]})
json_data
=
json
.
loads
(
json_util
.
dumps
(
cursor
))
return
remove_mongodb_id_from_result
(
json_data
,
'
run
'
)
purged
=
remove_key_from_dict
(
json_data
,
'
cpu
'
)
return
remove_mongodb_id_from_result
(
purged
,
'
run
'
)
def
get_latest_runs
(
coll
:
collection
.
Collection
,
...
...
@@ -119,7 +124,9 @@ def get_latest_runs(coll: collection.Collection,
{
'
metadata.ocr_workflow.id
'
:
wf_regex
},
{
'
metadata.timestamp
'
:
compile
(
closest_timestamp
)}]})
latest_run_json
=
json
.
loads
(
json_util
.
dumps
(
latest_run
))
return
remove_mongodb_id_from_result
(
latest_run_json
,
'
run
'
)
purged
=
remove_key_from_dict
(
latest_run_json
,
'
cpu
'
)
return
remove_mongodb_id_from_result
(
purged
,
'
run
'
)
def
get_latest_runs_per_gt
(
coll
:
collection
.
Collection
,
...
...
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