Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
OpenFold
Commits
7ea9c9e4
Unverified
Commit
7ea9c9e4
authored
Aug 12, 2022
by
Gustaf Ahdritz
Committed by
GitHub
Aug 12, 2022
Browse files
Merge pull request #201 from brianloyal/timings
Write inference and relaxation timings to a file
parents
6e930a6c
450f5236
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
run_pretrained_openfold.py
run_pretrained_openfold.py
+21
-1
No files found.
run_pretrained_openfold.py
View file @
7ea9c9e4
...
...
@@ -120,6 +120,7 @@ def run_model(model, batch, tag, args):
out
=
model
(
batch
)
inference_time
=
time
.
perf_counter
()
-
t
logger
.
info
(
f
"Inference time:
{
inference_time
}
"
)
update_timings
({
"inference"
:
inference_time
},
os
.
path
.
join
(
args
.
output_dir
,
"timings.json"
))
model
.
config
.
template
.
enabled
=
template_enabled
...
...
@@ -480,7 +481,10 @@ def main(args):
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
device_no
relaxed_pdb_str
,
_
,
_
=
amber_relaxer
.
process
(
prot
=
unrelaxed_protein
)
os
.
environ
[
"CUDA_VISIBLE_DEVICES"
]
=
visible_devices
logger
.
info
(
f
"Relaxation time:
{
time
.
perf_counter
()
-
t
}
"
)
relaxation_time
=
time
.
perf_counter
()
-
t
logger
.
info
(
f
"Relaxation time:
{
relaxation_time
}
"
)
update_timings
({
"relaxation"
:
relaxation_time
},
os
.
path
.
join
(
args
.
output_dir
,
"timings.json"
))
# Save the relaxed PDB.
relaxed_output_path
=
os
.
path
.
join
(
...
...
@@ -500,6 +504,22 @@ def main(args):
logger
.
info
(
f
"Model output written to
{
output_dict_path
}
..."
)
def
update_timings
(
dict
,
output_file
=
os
.
path
.
join
(
os
.
getcwd
(),
"timings.json"
)):
"""Write dictionary of one or more run step times to a file"""
import
json
if
os
.
path
.
exists
(
output_file
):
with
open
(
output_file
,
"r"
)
as
f
:
try
:
timings
=
json
.
load
(
f
)
except
json
.
JSONDecodeError
:
logger
.
info
(
f
"Overwriting non-standard JSON in
{
output_file
}
."
)
timings
=
{}
else
:
timings
=
{}
timings
.
update
(
dict
)
with
open
(
output_file
,
"w"
)
as
f
:
json
.
dump
(
timings
,
f
)
return
output_file
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment