Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
c21655a1
Commit
c21655a1
authored
8 years ago
by
Nathaniel Kofalt
Browse files
Options
Downloads
Plain Diff
Merge pull request #265 from scitran/gear-config
Gear config
parents
1b732076
aec57e60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/jobs.py
+15
-6
15 additions, 6 deletions
api/jobs.py
api/rules.py
+8
-22
8 additions, 22 deletions
api/rules.py
with
23 additions
and
28 deletions
api/jobs.py
+
15
−
6
View file @
c21655a1
...
...
@@ -49,14 +49,23 @@ Category = util.Enum('Category', {
Gear
=
namedtuple
(
'
gear
'
,
[
'
name
'
,
'
category
'
,
'
input
'
])
Gears
=
[
Gear
(
'
dicom_mr_classifier
'
,
Category
.
classifier
,
{
'
type
'
:
'
file
'
,
'
location
'
:
'
/
'
,
'
uri
'
:
'
/opt/flywheel-temp/dicom_mr_classifier-bali.3.0-rc.2.tar
'
}),
Gear
(
'
dcm_convert
'
,
Category
.
converter
,
{
'
type
'
:
'
file
'
,
'
location
'
:
'
/
'
,
'
uri
'
:
'
/opt/flywheel-temp/dcm_convert-bali.3.0-rc.2.tar
'
}),
Gear
(
'
qa-report-fmri
'
,
Category
.
qa
,
{
'
type
'
:
'
file
'
,
'
location
'
:
'
/
'
,
'
uri
'
:
'
/opt/flywheel-temp/qa-report-fmri-bali.3.0-rc.2.tar
'
})
]
def
get_gears
():
"""
Fetch the install-global gears from the database
"""
gear_doc
=
config
.
db
.
static
.
find_one
({
'
_id
'
:
'
gears
'
})
gears_map
=
gear_doc
[
'
gear_list
'
]
gears
=
[]
for
g
in
gears_map
:
cat_string
=
g
[
'
category
'
]
gears
.
append
(
Gear
(
g
[
'
name
'
],
Category
[
cat_string
],
g
[
'
input
'
]))
return
gears
def
get_gear_by_name
(
name
):
for
gear
in
G
ears
:
for
gear
in
get_g
ears
()
:
if
gear
.
name
==
name
:
return
gear
raise
Exception
(
"
Unknown gear
"
+
name
)
...
...
This diff is collapsed.
Click to expand it.
api/rules.py
+
8
−
22
View file @
c21655a1
import
fnmatch
import
json
from
.
import
jobs
from
.
import
config
...
...
@@ -34,27 +35,12 @@ MATCH_TYPES = [
'
container.has-type
'
]
# TODO: replace with default rules, which get persisted, maintained, upgraded, and reasoned intelligently
HARDCODED_RULES
=
[
{
'
alg
'
:
'
dicom_mr_classifier
'
,
'
all
'
:
[
[
'
file.type
'
,
'
dicom
'
]
]
},
{
'
alg
'
:
'
dcm_convert
'
,
'
all
'
:
[
[
'
file.type
'
,
'
dicom
'
]
]
},
{
'
alg
'
:
'
qa-report-fmri
'
,
'
all
'
:
[
[
'
file.type
'
,
'
nifti
'
]
]
}
]
def
get_base_rules
():
"""
Fetch the install-global gear rules from the database
"""
rule_doc
=
config
.
db
.
static
.
find_one
({
'
_id
'
:
'
rules
'
})
return
rule_doc
[
'
rule_list
'
]
def
_log_file_key_error
(
file_
,
container
,
error
):
log
.
warning
(
'
file
'
+
file_
.
get
(
'
name
'
,
'
?
'
)
+
'
in container
'
+
str
(
container
.
get
(
'
_id
'
,
'
?
'
))
+
'
'
+
error
)
...
...
@@ -137,7 +123,7 @@ def create_jobs(db, container, container_type, file_):
rules
=
get_rules_for_container
(
db
,
container
)
# Add hardcoded rules that cannot be removed or changed
for
hardcoded_rule
in
HARDCODED_RULES
:
for
hardcoded_rule
in
get_base_rules
()
:
rules
.
append
(
hardcoded_rule
)
for
rule
in
rules
:
...
...
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