-
Notifications
You must be signed in to change notification settings - Fork 232
topic/graph strategy #231
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
topic/graph strategy #231
Conversation
fscherf
commented
Apr 13, 2018
- Add graph based strategies
- Setup coverage in local test suite
- Some fixes
124c741 to
f4578da
Compare
Codecov Report
@@ Coverage Diff @@
## master #231 +/- ##
========================================
+ Coverage 54.6% 55.5% +0.8%
========================================
Files 99 100 +1
Lines 5678 5786 +108
========================================
+ Hits 3105 3213 +108
Misses 2573 2573
Continue to review full report at Codecov.
|
| All states **HAVE TO**: | ||
| 1. Be a method of a `GraphStrategy` subclass | ||
| 2. Use this prototype: `def state_$STATENAME(self):` | ||
| 3. Not call `transition()` in its state definition |
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.
Document that exactly one state without dependencies is required.
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.
Do have the lines 295 and 295 not have enough information?
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.
Looks fine.
doc/development.rst
Outdated
| >>> graph_strategy.graph.render('filename') | ||
| 'filename.png' | ||
| .. image:: res/grapstrategy-1.png |
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.
Fix typo in filename (missing 'h').
.coveragerc
Outdated
| @@ -1,3 +1,6 @@ | |||
| [run] | |||
| branch = 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.
This should be a separate PR.
labgrid/strategy/graphstrategy.py
Outdated
| method = getattr(self, state_name) | ||
|
|
||
| if not callable(method): | ||
| continue |
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.
This should be rejected as invalid.
labgrid/strategy/graphstrategy.py
Outdated
| for dependency in self.states[state_name]['dependencies']: | ||
| if dependency not in state_names: | ||
| raise InvalidGraphStrategyError( | ||
| "State '{}' is unknown. State names are: {}".format( |
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.
Report which state has a missing dependency.
|
|
||
| finally: | ||
| # unlock transition | ||
| self.__transition_running = False |
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.
Do we want to call invalidate if an exception occurs?
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 think the transition should stop in this case and remain at the previous state
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.
If the exception occurs after some code in the state_ function was called (such as power changes), the previous state is no longer correct. So I'd prefer to invalidate().
labgrid/strategy/graphstrategy.py
Outdated
| while current_state['dependencies']: | ||
| next_state = current_state['dependencies'][0] | ||
|
|
||
| if via: |
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 if is redundant (for on an empty list does nothing).
| # unlock transition | ||
| self.__transition_running = False | ||
|
|
||
| def find_abs_path(self, state, via=[]): |
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.
Add a docstring to explain how this works.
|
|
||
| dg.edge(edge, node_name) | ||
|
|
||
| self._graph_cache['graph'] = dg |
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.
How much time does this save?
| @@ -0,0 +1,222 @@ | |||
| import pytest | |||
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.
Add test which throws an exception.
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
f4578da to
890b6f4
Compare
|
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
Signed-off-by: Florian Scherf <f.scherf@pengutronix.de>
890b6f4 to
ae39eeb
Compare