{"action":"created","issue":{"url":"https://api.github.com/repos/OpenTrons/opentrons/issues/336","repository_url":"https://api.github.com/repos/OpenTrons/opentrons","labels_url":"https://api.github.com/repos/OpenTrons/opentrons/issues/336/labels{/name}","comments_url":"https://api.github.com/repos/OpenTrons/opentrons/issues/336/comments","events_url":"https://api.github.com/repos/OpenTrons/opentrons/issues/336/events","html_url":"https://github.com/OpenTrons/opentrons/pull/336","id":256552600,"number":336,"title":"Add support for commands nesting, remove commands list from robot, clean-up notifications","user":{"login":"astaff","id":1032174,"avatar_url":"https://avatars3.githubusercontent.com/u/1032174?v=4","gravatar_id":"","url":"https://api.github.com/users/astaff","html_url":"https://github.com/astaff","followers_url":"https://api.github.com/users/astaff/followers","following_url":"https://api.github.com/users/astaff/following{/other_user}","gists_url":"https://api.github.com/users/astaff/gists{/gist_id}","starred_url":"https://api.github.com/users/astaff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astaff/subscriptions","organizations_url":"https://api.github.com/users/astaff/orgs","repos_url":"https://api.github.com/users/astaff/repos","events_url":"https://api.github.com/users/astaff/events{/privacy}","received_events_url":"https://api.github.com/users/astaff/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-09-11T00:21:11Z","updated_at":"2017-09-19T03:41:50Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/OpenTrons/opentrons/pulls/336","html_url":"https://github.com/OpenTrons/opentrons/pull/336","diff_url":"https://github.com/OpenTrons/opentrons/pull/336.diff","patch_url":"https://github.com/OpenTrons/opentrons/pull/336.patch"},"body":"## Add support for commands nesting\r\n\r\n`commands` attribute in `Session` now reflects nesting levels for protocol commands. This is achieved by session listening to `robot.command` and adding it to the stack on *before* event and removing it on *after*. This allows to track stack depth for each command being executed. Upon receiving all the commands during simulation we can reconstruct the tree through DFS traversal.\r\n\r\n## Remove commands list from robot\r\n\r\nAs an effort to remove state from `robot`, made `robot` and `pipette` emit `robot.command` and made `session` responsible for handling `robot.command`, mutating itself and emitting`session.state.change` sending `session` value that can be consumed by the UI.\r\n\r\nRemoval of commands, affected a lot of pipette tests that had to be refactored. To reduce code re-write, test setup monkeypatches `robot.commands` using session.\r\n\r\n## Clean-up notifications\r\n\r\nAs an effort to keep session code clean, following conversation with @jaredgreene1 and @mcous , made the following changes to EventBroker:\r\n  - Removed it from `utils` and moved to separate module, `opentrons.broker`.\r\n  - Moved functions from `EventBroker` class into `broker` module, as a cleaner way to implement singleton.\r\n  - Allowed listeners to `subscribe` to select names. With `handler` defined, it will call a handler passing event `name` and `payload`. If handler is not defined return `async iterable` to be used in `async for` statements. \r\n  - Moved `Notifications` from `session` to `broker`.\r\n  - Removed `@traceable` and introduced `publish.before, publish.after and publish.both` allowing event to be emitted before function call, after function call or both. \r\n  - Made decorator signature more explicit by removing name inference from function's FQN and adding a named argument.\r\n  - Made `broker.notify` take `name` as an argument\r\n  - Refactored code that used EventBroker\r\n\r\n## Notes\r\n\r\n- There *are* breaking changes in the API that need to be further explained: `robot.commands` is gone. We need to implement a protocol developer friendly way to use `session` for running the protocol and retrieving commands.\r\n- Per @jaredgreene1 and @mcous conversation, we should try to make event emission more explicit and have an option to define message types and notification factory, that would produce `notify` functions with named arguments.\r\n\r\nCheck List:\r\n\r\n- [x] Are there breaking changes in the API and how are they being communicated?\r\n- [ ] Who is reviewing your code?\r\n"},"comment":{"url":"https://api.github.com/repos/OpenTrons/opentrons/issues/comments/330420302","html_url":"https://github.com/OpenTrons/opentrons/pull/336#issuecomment-330420302","issue_url":"https://api.github.com/repos/OpenTrons/opentrons/issues/336","id":330420302,"user":{"login":"codecov[bot]","id":22429695,"avatar_url":"https://avatars2.githubusercontent.com/in/254?v=4","gravatar_id":"","url":"https://api.github.com/users/codecov%5Bbot%5D","html_url":"https://github.com/apps/codecov","followers_url":"https://api.github.com/users/codecov%5Bbot%5D/followers","following_url":"https://api.github.com/users/codecov%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/codecov%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/codecov%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codecov%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/codecov%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/codecov%5Bbot%5D/repos","events_url":"https://api.github.com/users/codecov%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/codecov%5Bbot%5D/received_events","type":"Bot","site_admin":false},"created_at":"2017-09-19T03:41:50Z","updated_at":"2017-09-19T03:41:50Z","author_association":"NONE","body":"# [Codecov](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=h1) Report\n> Merging [#336](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=desc) into [app-3-0](https://codecov.io/gh/OpenTrons/opentrons/commit/1c61718aa19fcf39e5b469c5a486ce1e65803f18?src=pr&el=desc) will **decrease** coverage by `0.97%`.\n> The diff coverage is `98.24%`.\n\n[![Impacted file tree graph](https://codecov.io/gh/OpenTrons/opentrons/pull/336/graphs/tree.svg?token=DIJPWI1JiU&width=650&height=150&src=pr)](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree)\n\n```diff\n@@             Coverage Diff             @@\n##           app-3-0     #336      +/-   ##\n===========================================\n- Coverage    81.41%   80.43%   -0.98%     \n===========================================\n  Files           63       67       +4     \n  Lines         4465     4840     +375     \n===========================================\n+ Hits          3635     3893     +258     \n- Misses         830      947     +117\n```\n\n\n| [Impacted Files](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree) | Coverage Δ | |\n|---|---|---|\n| [api/opentrons/helpers/helpers.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9oZWxwZXJzL2hlbHBlcnMucHk=) | `98.29% <ø> (-0.07%)` | :arrow_down: |\n| [api/opentrons/session/\\_\\_init\\_\\_.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9zZXNzaW9uL19faW5pdF9fLnB5) | `100% <ø> (ø)` | :arrow_up: |\n| [api/tests/opentrons/broker/\\_\\_init\\_\\_.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL3Rlc3RzL29wZW50cm9ucy9icm9rZXIvX19pbml0X18ucHk=) | `100% <ø> (ø)` | |\n| [api/tests/opentrons/commands/\\_\\_init\\_\\_.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL3Rlc3RzL29wZW50cm9ucy9jb21tYW5kcy9fX2luaXRfXy5weQ==) | `100% <ø> (ø)` | |\n| [...pentrons/drivers/smoothie\\_drivers/v2\\_0\\_0/driver.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9kcml2ZXJzL3Ntb290aGllX2RyaXZlcnMvdjJfMF8wL2RyaXZlci5weQ==) | `92.59% <100%> (ø)` | :arrow_up: |\n| [api/opentrons/commands/tree.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9jb21tYW5kcy90cmVlLnB5) | `100% <100%> (ø)` | |\n| [api/opentrons/instruments/pipette.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9pbnN0cnVtZW50cy9waXBldHRlLnB5) | `97.85% <100%> (-0.27%)` | :arrow_down: |\n| [api/opentrons/commands/types.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9jb21tYW5kcy90eXBlcy5weQ==) | `100% <100%> (ø)` | |\n| [...pentrons/drivers/smoothie\\_drivers/v1\\_2\\_0/driver.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9kcml2ZXJzL3Ntb290aGllX2RyaXZlcnMvdjFfMl8wL2RyaXZlci5weQ==) | `91.05% <100%> (+0.02%)` | :arrow_up: |\n| [api/opentrons/session/session.py](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree#diff-YXBpL29wZW50cm9ucy9zZXNzaW9uL3Nlc3Npb24ucHk=) | `92.96% <100%> (+3.81%)` | :arrow_up: |\n| ... and [28 more](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=tree-more) | |\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=continue).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)\n> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=footer). Last update [1c61718...45e38b4](https://codecov.io/gh/OpenTrons/opentrons/pull/336?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).\n"}}
{"actor":{"display_login":"codecov"}}