Add media bottle support to graphing tool#24
Conversation
dgruano
left a comment
There was a problem hiding this comment.
As a general comment, the code is written assuming that the user will create the bottles.txt file correctly (but we can modify it to catch most possible errors).
| rootdir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | ||
| evolver_dir = os.path.join(rootdir, 'experiment') | ||
| pump_cal = os.path.join(evolver_dir, expt_subdir[0], "pump_cal.txt") | ||
| bottle_file = os.path.join(evolver_dir, expt_subdir[0], "bottles.txt") |
There was a problem hiding this comment.
Where should we place the bottles.txt file?
TestExperiment/bottles.txtTestExperiment/TestExperiment_expt/bottles.txt
There was a problem hiding this comment.
The second is better I think - that way bottle consumption is tracked with an actual experiment that is being run. If it's in the higher-level dir, new experiments run on the same code can clear the logs of other expts.
| expt_pickle = os.path.join(evolver_dir, expt_subdir[0], expt_dir[0], expt_dir[0] + ".pickle") | ||
|
|
||
| if not os.path.isfile(bottle_file): | ||
| open(bottle_file, 'w') |
There was a problem hiding this comment.
File could be created in eVOLVER.py when the rest of the experiment files are created, but I did not want to touch It for the moment.
There was a problem hiding this comment.
It's better to just have the script generate a generic file if it is not created by the user. Or have a generic file pre-checked in to the template directory and add some documentation around the usage of it.
Allow the user to define which media bottles are connected to which vials. This way, media consumption per bottle can be calculated. This commit adds a configuration file, a table with the bottle consumption and an interactive interface with two modals: - Edit bottle setup: user can write the list of media bottles, their volume, and the vials they are connected to. - See bottle setup: current setup is displayed, and user can notify when they change a bottle. This info will be logged in the bottle.txt configuration file. The bottle configuration is stored in a txt file inside the experiment folder and timestamps are added when bottles are changed. Whenever the bottle/vial configuration is changed, a new file is created and former setup is backed up. Only the media consumed from the currently plugged bottle is calculated, therefore allowing for a future notification system when a bottle is running low.
0e6f455 to
67b2079
Compare
| if not bottle_data: | ||
| bottle_info = None | ||
| else: | ||
| # bottleID vials volume0 timestamp0 ... volumeN timestampN |
There was a problem hiding this comment.
So this file can have arbitrary columns - they just get additional columns added every time the user changes the bottle? I think having the file be row based is better, new events just require adding a row as opposed to essentially re-writing the entire file when you update a bottle at the top of the file. Also you will end up with lots of blanks for bottles that don't get replaced at the same rates if you maintain column structure.
Since everything is timestamped you would just find the latest event with that. Then this file becomes more of a log of bottle changes vs a database type table. Happy to hear your thoughts though if you disagree.
| except IndexError: | ||
| bottle_consumption = -1 # Error when slicing the data | ||
| else: | ||
| bottle_consumption = -2 # Bottle has no vials assigned |
There was a problem hiding this comment.
Are these negative flags used elsewhere? You could just make custom exceptions. Both of these cases seem like there is either something wrong with the data or something wrong with how the user configured the file. In both cases the user should be informed (some sort of indicator on the page).
| {% endif %} | ||
| {% endfor %} | ||
| </tr> | ||
| <!--<tr> |
There was a problem hiding this comment.
Remove this if it's not being used.
What? Why?
Allow the user to define which media bottles are connected to which
vials. This way, media consumption per bottle can be calculated.
This PR adds a configuration file, a table with the bottle
consumption and an interactive interface with two modals:
Edit bottle setup: user can write the list of media bottles,
their volume, and the vials they are connected to.
See bottle setup: current setup is displayed, and user can notify
when they change a bottle. This info will be logged in the bottle.txt
configuration file.
The bottle configuration is stored in a txt file inside the experiment
folder and timestamps are added when bottles are changed. Whenever the
bottle/vial configuration is changed, a new file is created and former
setup is backed up.
Only the media consumed from the currently plugged bottle is calculated,
therefore allowing for a future notification system when a bottle is
running low.
Checks
Any screenshots or GIFs?