-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding a post hook that can run a measurement - try 2 #151
base: main
Are you sure you want to change the base?
Conversation
# Conflicts: # docs/source/user_guide/measure_edition.rst
adding the methods to save/load the file correcting the executions infos # Conflicts: # docs/source/dev_guide/measurement.rst
The Travis failing is probably related to some assumption done in the tests about the absence of more tools than the one considered. I have not looked at it in details yet. |
Codecov Report
@@ Coverage Diff @@
## master #151 +/- ##
=========================================
- Coverage 98.38% 97.88% -0.5%
=========================================
Files 157 158 +1
Lines 12293 12366 +73
=========================================
+ Hits 12094 12104 +10
- Misses 199 262 +63 |
"""Post-execusion hook to add a hierarchy of tasks. | ||
|
||
""" | ||
root_task = Typed(RootTask) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All those attributes should be documented using #: comments.
dependencies = Tuple() | ||
|
||
def __init__(self, declaration, workbench): | ||
""" Create an empty root task |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No docstring for __init__ the class docstring is sufficient.
""" Widget used for the AddTaskHook | ||
|
||
""" | ||
attr hook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same those deserve a #: comment
id = 'post-execution' | ||
point = manifest.id + '.post-execution' | ||
PostExecutionHook: | ||
id = 'exopy.addtask_hook' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must say I am not a big fan fan of this name... RunTaskHook perhaps ?
"""Create an AddTaskView. | ||
|
||
""" | ||
# on est obligé d'aller chercher dans le vrai manifest de measurement pour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In English please.
# assert hook.engine | ||
|
||
|
||
def test_get_state(addtaskhook): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testing get_state and set_state can be combined to avoid painful manual checking of the config and manual construction of it.
""" | ||
addtaskhook.engine = DummyEngine() | ||
addtaskhook.stop(force=True) | ||
assert addtaskhook.engine.stop_called == True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stop_called
does not exist because it was not needed in other tests. You can either edit the dummy or use _stop
addtaskhook.stop(force=True) | ||
assert addtaskhook.engine.stop_called == True | ||
|
||
def test_view(addtaskview, addtaskhook): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we would like to show the widget to check it at least displays properly.
# ca devrait marcher pcq on appelle une seule fois la fixture, ensuite c'est le même objet | ||
assert rootview.task == addtaskhook.root_task | ||
|
||
def test_list_runtimes(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To test this the easiest way is to monkeypatch the infos of a task to add it a dependencies it does not have you can have a look at tests\tasks\test_dependencies.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just looked at the changes not at Travis.
root_task = Typed(RootTask) | ||
|
||
#: Reference to the measurement workbench |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
application workbench
The workbench is shared by the whole application and is not specific to the measurement plugin.
attr declaration | ||
|
||
#: Reference to the corresponding measurement workbench |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
# 'task_id': 'DummyTask'}} | ||
assert task_prefs # blabla selon sa structure | ||
|
||
assert task_prefs # blabla selon sa structure ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment can go away, no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked quickly at Travis failures and left some indications on how to fix them.
# on est obligé d'aller chercher dans le vrai manifest de measurement pour | ||
# trouver le make_view | ||
meas = measurement_workbench.get_plugin('exopy.measurement') | ||
decl = meas.get_declarations('exopy.addtask_hook') # check how to get the declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to specify that 'exopy.addtask_hook' is a post_hook using the first argument of get_declarations.
""" | ||
assert type(addtaskhook.root_task) == RootTask | ||
assert type(addtaskhook.workbench) == Workbench | ||
assert type(addtaskhook.dependencies) == Tuple |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are mixing the type of the decorator and the type of the value it returns. It should be tuple.
assert type(addtaskview.widget()[0]) == RootTaskView | ||
rootview = addtaskview.widget()[0] | ||
assert rootview.show_path == False | ||
# ca devrait marcher pcq on appelle une seule fois la fixture, ensuite c'est le même objet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In english please.
|
||
|
||
@pytest.fixture | ||
def addtaskhook(measurement): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to make sure the TaskPlugin is registered. requesting the task_workbench should work.
As requested in issue #17