Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by chucksmash on Monday February 15, 2016 @02:32PM
(#11105359)
From Github's Scientist [1]:
Because `enabled?` and `run_if` determine when a candidate runs, it's impossible to guarantee that it will run every time. For this reason, Scientist is only safe for wrapping methods that aren't changing data.
When using Scientist, we've found it most useful to modify both the existing and new systems simultaneously anywhere writes happen, and verify the results at read time with `science`.
Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by jack_jennings on Monday February 15, 2016 @06:02PM
(#11106725)
Before clicking the link I wondered how this would translate the block-based Ruby API into Python. Using Python's with statement is quite nice here, I think.
The with statement is one of my favorite additions to the language. It's a really flexible syntax to encapsulate control flow, exceptions, necessary cleanup steps… etc. etc.
Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by msellout on Tuesday February 16, 2016 @12:22AM
(#11108047)
A decorator must be applied to a function or class, whereas a context manager can wrap an arbitrary section of code. So, it depends on how you want the tool to be used. I don't think there's a clear best design.
Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by buttscicles on Tuesday February 16, 2016 @04:49AM
(#11108834)
This was my thought as well, and it's also a bit more awkward if your function signatures differ. Luckily they aren't mutually exclusive and it should be easy to implement a decorator version.
Re:Show HN: Laboratory, a Python port of GitHub's Scientist ...
by agentultra on Monday February 15, 2016 @02:12PM
(#11105237)
Cool! Thanks for the tool!
> Imagine you've implemented a complex caching strategy for some objects in your database and a stale cache is simply not acceptable.
I hope you have a formal specification of that cache. That will help ensure your design is correct in the first place before you even get to running it in code.
PHP
https://github.com/LartTyler/Analyst
Javascript
https://github.com/trello/scientist
https://github.com/Runnable/scientist
https://github.com/jirwin/labrat
http://haacked.com/archive/2016/01/20/scientist/
Because `enabled?` and `run_if` determine when a candidate runs, it's impossible to guarantee that it will run every time. For this reason, Scientist is only safe for wrapping methods that aren't changing data.
When using Scientist, we've found it most useful to modify both the existing and new systems simultaneously anywhere writes happen, and verify the results at read time with `science`.
[1]: https://github.com/github/scientist/blob/master/README.md#de...
The with statement is one of my favorite additions to the language. It's a really flexible syntax to encapsulate control flow, exceptions, necessary cleanup steps… etc. etc.
> Imagine you've implemented a complex caching strategy for some objects in your database and a stale cache is simply not acceptable.
I hope you have a formal specification of that cache. That will help ensure your design is correct in the first place before you even get to running it in code.
I shall be playing with this soon. Cheers!