Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
adega
adega
Commits
13adf8b6
Commit
13adf8b6
authored
Jul 24, 2019
by
Odair M.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes adega:
#214
: implement command analyze_all
parent
b1b667b8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
1 deletion
+69
-1
src/adega/management/commands/analyze_all.py
src/adega/management/commands/analyze_all.py
+30
-0
src/adega/management/commands/analyze_last_all.py
src/adega/management/commands/analyze_last_all.py
+30
-0
src/submission/analysis/main.py
src/submission/analysis/main.py
+1
-0
src/submission/models.py
src/submission/models.py
+8
-1
No files found.
src/adega/management/commands/analyze_all.py
0 → 100644
View file @
13adf8b6
from
django.core.management.base
import
BaseCommand
from
submission.models
import
Submission
from
degree.models
import
Degree
from
submission.analysis.main
import
analyze
class
Command
(
BaseCommand
):
help
=
' Reexecute last analyze of all degree'
def
handle
(
self
,
*
args
,
**
options
):
degrees
=
Degree
.
objects
.
all
()
submissions
=
Submission
.
objects
.
all
()
to_analyze
=
[]
# for each degree, get last submission with sucessful and re execute
for
degree
in
degrees
:
# get all submissions of degree
submissions
=
Submission
.
objects
.
filter
(
degree
=
degree
,
analysis_status
=
Submission
.
STATUS_FINISHED
)
# check if degree has submissions
if
len
(
submissions
)
>
0
:
# Put each submission on queue and set it to executing status
for
submission
in
submissions
.
order_by
(
'timestamp'
):
submission
.
set_executing
()
to_analyze
.
append
(
submission
)
# Execute each analyze in chronological order
for
submission
in
to_analyze
:
analyze
(
submission
)
src/adega/management/commands/analyze_last_all.py
0 → 100644
View file @
13adf8b6
from
django.core.management.base
import
BaseCommand
from
submission.models
import
Submission
from
degree.models
import
Degree
from
submission.analysis.main
import
analyze
class
Command
(
BaseCommand
):
help
=
' Reexecute last analyze of all degree'
def
handle
(
self
,
*
args
,
**
options
):
degrees
=
Degree
.
objects
.
all
()
submissions
=
Submission
.
objects
.
all
()
to_analyze
=
[]
# for each degree, get last submission with sucessful and re execute
for
degree
in
degrees
:
# get all submissions of degree
submissions
=
Submission
.
objects
.
filter
(
degree
=
degree
,
analysis_status
=
Submission
.
STATUS_FINISHED
)
# check if degree has submissions
if
len
(
submissions
)
>
0
:
# sort reverse submission by timestamp and the most recent submission
submission
=
submissions
.
order_by
(
'timestamp'
).
reverse
()[
0
]
submission
.
set_executing
()
to_analyze
.
append
(
submission
)
# Execute each analyze in chronological order
for
submission
in
to_analyze
:
analyze
(
submission
)
\ No newline at end of file
src/submission/analysis/main.py
View file @
13adf8b6
...
...
@@ -9,6 +9,7 @@ import traceback
def
analyze
(
submission
,
debug
=
True
):
start_time
=
time
.
clock
()
start_time_exec
=
time
.
time
()
submission
.
set_executing
()
try
:
path
=
submission
.
path
()
dataframe
=
load_dataframes
(
path
)
...
...
src/submission/models.py
View file @
13adf8b6
...
...
@@ -37,7 +37,7 @@ class Submission(models.Model):
historico
=
models
.
FileField
(
upload_to
=
get_path
)
matricula
=
models
.
FileField
(
upload_to
=
get_path
)
degree
=
models
.
ForeignKey
(
Degree
)
degree
=
models
.
ForeignKey
(
Degree
,
related_name
=
'submissions'
)
timestamp
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
last
=
models
.
BooleanField
(
default
=
True
)
processed
=
models
.
BooleanField
(
default
=
False
)
...
...
@@ -89,6 +89,13 @@ class Submission(models.Model):
self
.
degree
.
name
,
self
.
timestamp
)
def
set_executing
(
self
):
self
.
processed
=
False
self
.
process_time
=
None
self
.
done_in
=
timezone
.
now
()
self
.
analysis_status
=
0
self
.
save
()
def
set_done
(
self
,
time
):
self
.
processed
=
True
self
.
process_time
=
time
...
...
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