Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gwcelery
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Container Registry
Model registry
Operate
Environments
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 GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sushant Sharma-Chaudhary
gwcelery
Commits
e8128cfc
Commit
e8128cfc
authored
1 year ago
by
Cody Messick
Committed by
Brandon Piotrzkowski
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Only import GWSkyNet at task scope
parent
9e121237
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gwcelery/tasks/gwskynet.py
+15
-4
15 additions, 4 deletions
gwcelery/tasks/gwskynet.py
with
15 additions
and
4 deletions
gwcelery/tasks/gwskynet.py
+
15
−
4
View file @
e8128cfc
"""
GWSkyNet annotation with GWSkyNet model
"""
from
functools
import
cache
import
json
import
re
from
GWSkyNet
import
GWSkyNet
import
numpy
as
np
from
.
import
gracedb
,
igwn_alert
,
superevents
from
..
import
app
from
..util.tempfile
import
NamedTemporaryFile
from
..util
import
PromiseProxy
GWSkyNet_model
=
PromiseProxy
(
GWSkyNet
.
load_GWSkyNet_model
)
manual_pref_event_change_regexp
=
re
.
compile
(
app
.
conf
[
'
views_manual_preferred_event_log_message
'
].
replace
(
'
.
'
,
'
\\
.
'
)
.
replace
(
'
{}
'
,
'
.+
'
)
)
@cache
def
GWSkyNet_model
():
# FIXME Remove import from function scope once importing GWSkyNet is not a
# slow operation
from
GWSkyNet
import
GWSkyNet
return
GWSkyNet
.
load_GWSkyNet_model
()
@app.task
(
queue
=
'
skynet
'
,
shared
=
False
)
def
gwskynet_annotation
(
filecontents
):
"""
Perform the series of tasks necessary for GWSkyNet to
...
...
@@ -28,9 +35,13 @@ def gwskynet_annotation(filecontents):
GWSkyNet_model : keras.engine.functional.Functional object
the GWSkyNet model used to annotate the events
"""
# FIXME Remove import from function scope once importing GWSkyNet is not a
# slow operation
from
GWSkyNet
import
GWSkyNet
with
NamedTemporaryFile
(
content
=
filecontents
)
as
fitsfile
:
GWSkyNet_input
=
GWSkyNet
.
prepare_data
(
fitsfile
.
name
)
class_score
=
GWSkyNet
.
predict
(
GWSkyNet_model
,
GWSkyNet_input
)
class_score
=
GWSkyNet
.
predict
(
GWSkyNet_model
()
,
GWSkyNet_input
)
FAP
,
FNP
=
GWSkyNet
.
get_rates
(
class_score
)
fap
=
FAP
[
0
]
fnp
=
FNP
[
0
]
...
...
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