Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
digitalearth
DASF Data Analytics Software Framework
dasf-progress-api
Commits
2db51726
Commit
2db51726
authored
Jul 01, 2021
by
Daniel Eggert
Browse files
updated example.py
parent
9482344f
Changes
2
Hide whitespace changes
Inline
Side-by-side
example.py
0 → 100644
View file @
2db51726
if
__name__
==
"__main__"
:
from
deprogressapi
import
ProgressReport
,
FormalProgressInterface
# dummy send handler
class
ProgressImplementation
(
FormalProgressInterface
):
def
send
(
self
,
progress_json
:
str
):
pass
# create the (dummy) send handler
progress_send_handler
=
ProgressImplementation
()
# create the root report
pr1
=
ProgressReport
(
'Init'
,
send_handler
=
progress_send_handler
,
steps
=
2
)
# create a sub report
pr1_sub1
=
pr1
.
create_subreport
(
step_message
=
'Step 1.1 - Download'
)
# run the corresponding task ...
# complete the sub report
pr1_sub1
.
complete
()
# create another sub report with pre-determined number of steps
pr1_sub2
=
pr1
.
create_subreport
(
step_message
=
'Step 1.2 - Process Download'
,
steps
=
2
)
# create corresponding sub-sub reports
pr1_sub21
=
pr1_sub2
.
create_subreport
(
step_message
=
'Step 1.2.1 - Process Download'
)
# ...
pr1_sub21
.
complete
()
pr1_sub22
=
pr1_sub2
.
create_subreport
(
step_message
=
'Step 1.2.2 - Process Download'
)
# ...
pr1_sub22
.
complete
()
pr1_sub2
.
complete
()
pr1
.
complete
()
test.py
deleted
100644 → 0
View file @
9482344f
from
deprogressapi
import
ProgressReport
,
FormalProgressInterface
class
ProgressImplementation
(
FormalProgressInterface
):
def
send
(
self
,
progress_json
:
str
):
pass
progress_send_handler
=
ProgressImplementation
()
pr1
=
ProgressReport
(
'Init'
,
send_handler
=
progress_send_handler
,
steps
=
2
)
pr1_sub1
=
pr1
.
create_subreport
(
step_message
=
'Step 1.1 - Download'
)
pr1_sub2
=
pr1
.
create_subreport
(
step_message
=
'Step 1.2 - Process Download'
,
steps
=
2
)
pr1_sub21
=
pr1_sub2
.
create_subreport
(
step_message
=
'Step 1.2.1 - Process Download'
)
pr1_sub22
=
pr1_sub2
.
create_subreport
(
step_message
=
'Step 1.2.2 - Process Download'
)
data
=
progress_send_handler
.
get_data
()
print
(
data
[
'step_message'
]
==
'Init'
)
print
(
data
[
'children'
][
0
][
'step_message'
]
==
'Step 1.1 - Download'
)
print
(
data
[
'children'
][
1
][
'children'
][
0
][
'step_message'
]
==
'Step 1.2.1 - Process Download'
)
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