Skip to content

Add media bottle support to graphing tool#24

Open
dgruano wants to merge 1 commit intoFYNCH-BIO:rcfrom
dgruano:graph-bottles
Open

Add media bottle support to graphing tool#24
dgruano wants to merge 1 commit intoFYNCH-BIO:rcfrom
dgruano:graph-bottles

Conversation

@dgruano
Copy link
Copy Markdown
Contributor

@dgruano dgruano commented Sep 8, 2020

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

  • Updated documentation.
  • Follows 7 rules of great commit messages. For most PRs a single commit should suffice, in some cases multiple topical commits can be useful. During review it is ok to see tiny commits (e.g. Fix reviewer comments), but right before the code gets merged to master or rc branch, any such commits should be squashed since they are useless to the other developers. Definitely avoid merge commits, use rebase instead.
  • Follows the Google Style Guide.

Any screenshots or GIFs?

See setup and plug new bottles

Create a new config file

Bottle table

Copy link
Copy Markdown
Contributor Author

@dgruano dgruano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where should we place the bottles.txt file?

  • TestExperiment/bottles.txt
  • TestExperiment/TestExperiment_expt/bottles.txt

Copy link
Copy Markdown
Contributor

@zheins zheins Oct 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
if not bottle_data:
bottle_info = None
else:
# bottleID vials volume0 timestamp0 ... volumeN timestampN
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this if it's not being used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants