Skip to content

Commit

Permalink
rename some files; add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Dec 28, 2020
1 parent 20eac67 commit f5c8f61
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 21 deletions.
10 changes: 9 additions & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ pioreactor1=192.168.0.1
# a 1 means available, and a 0 means not available.
# See docs: https://github.com/Pioreactor/pioreactor/wiki/Leaders,-workers-and-inventory
pioreactor1=1

pioreactor2=1
pioreactor3=1
pioreactor4=0

[dashboard.settings]
# changing these requires a power cycle of the leader unit.
Expand All @@ -51,6 +53,8 @@ raw_od_lookback_minutes=240
log_display_count=65

[dashboard.charts]
# show/hide charts on the PioreactorUI dashboard
# 1 is show, 0 is hide
implied_growth_rate=1
fraction_of_volume_that_is_alternative_media=1
normalized_135_optical_density=1
Expand All @@ -66,6 +70,10 @@ Kp=5
Ki=0
Kd=0

[pid_turbidostat]
Kp=3
Ki=0.1
Kd=0.1

[watchdog]
email_alerts_to[email protected]
3 changes: 3 additions & 0 deletions pioreactor/actions/add_alt_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def cleanUpGPIO():
help="who is calling this function - data goes into database and MQTT",
)
def click_add_alt_media(ml, duration, duty_cycle, source_of_event):
"""
Add alt. media to unit
"""
unit = get_unit_name()
experiment = get_latest_experiment_name()

Expand Down
3 changes: 3 additions & 0 deletions pioreactor/actions/add_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ def cleanUpGPIO():
help="who is calling this function - data goes into database and MQTT",
)
def click_add_media(ml, duration, duty_cycle, source_of_event):
"""
Add media to unit
"""
unit = get_unit_name()
experiment = get_latest_experiment_name()

Expand Down
3 changes: 3 additions & 0 deletions pioreactor/actions/od_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def yield_from_mqtt():
""",
)
def click_od_normalization(od_angle_channel):
"""
Compute statistics about the OD timeseries
"""
unit = get_unit_name()
experiment = get_latest_experiment_name()
od_normalization(od_angle_channel, unit, experiment)
4 changes: 3 additions & 1 deletion pioreactor/actions/remove_waste.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def cleanUpGPIO():
help="who is calling this function - data goes into database and MQTT",
)
def click_remove_waste(ml, duration, duty_cycle, source_of_event):

"""
Remove waste/media from unit
"""
unit = get_unit_name()
experiment = get_latest_experiment_name()
signal.signal(signal.SIGTERM, cleanUpGPIO)
Expand Down
10 changes: 7 additions & 3 deletions pioreactor/background_jobs/io_controlling.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,14 @@ def __init__(self, target_od=None, volume=None, **kwargs):
self.volume = float(volume)

# PID%20controller%20turbidostat.ipynb
Kp = config.getFloat("pid_turbidostat", "Kp")
Ki = config.getFloat("pid_turbidostat", "Ki")
Kd = config.getFloat("pid_turbidostat", "Kd")

self.pid = PID(
-3.0,
-0.1,
-0.1,
-Kp,
-Ki,
-Kd,
setpoint=self.target_od,
output_limits=(0, 1),
sample_time=None,
Expand Down
2 changes: 1 addition & 1 deletion pioreactor/background_jobs/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_and_publish_disk_space(self):
@click.command(name="monitor")
def click_monitor():
"""
Start the watchdog on a unit. Reports back to the leader.
Monitor and report metadata on the unit.
"""
heidi = Monitor(unit=get_unit_name(), exp=UNIVERSAL_EXPERIMENT) # noqa: F841

Expand Down
25 changes: 13 additions & 12 deletions pioreactor/command_line_worker.py → pioreactor/pio_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
> pio log
"""
import click
from pioreactor.whoami import am_I_leader
from pioreactor.whoami import am_I_leader, am_I_active_worker
from pioreactor.config import config
from pioreactor import background_jobs as jobs
from pioreactor import actions
Expand Down Expand Up @@ -50,21 +50,22 @@ def kill(process):
pass


@pio.group()
def run(short_help="run a job"):
@pio.group(short_help="run a job")
def run():
pass


run.add_command(jobs.growth_rate_calculating.click_growth_rate_calculating)
run.add_command(jobs.stirring.click_stirring)
run.add_command(jobs.od_reading.click_od_reading)
run.add_command(jobs.io_controlling.click_io_controlling)
run.add_command(jobs.monitor.click_monitor)
if am_I_active_worker():
run.add_command(jobs.growth_rate_calculating.click_growth_rate_calculating)
run.add_command(jobs.stirring.click_stirring)
run.add_command(jobs.od_reading.click_od_reading)
run.add_command(jobs.io_controlling.click_io_controlling)
run.add_command(jobs.monitor.click_monitor)

run.add_command(actions.add_alt_media.click_add_alt_media)
run.add_command(actions.add_media.click_add_media)
run.add_command(actions.remove_waste.click_remove_waste)
run.add_command(actions.od_normalization.click_od_normalization)
run.add_command(actions.add_alt_media.click_add_alt_media)
run.add_command(actions.add_media.click_add_media)
run.add_command(actions.remove_waste.click_remove_waste)
run.add_command(actions.od_normalization.click_od_normalization)

if am_I_leader():
run.add_command(jobs.log_aggregating.click_log_aggregating)
Expand Down
File renamed without changes.
8 changes: 7 additions & 1 deletion pioreactor/whoami.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ def get_unit_name():
def am_I_leader():
from pioreactor.config import leader_hostname

return get_hostname() == leader_hostname
return get_unit_name() == leader_hostname


def am_I_active_worker():
from pioreactor.config import get_active_worker_units_and_ips

return get_unit_name() in get_active_worker_units_and_ips().keys()
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
packages=find_packages(exclude=["*.tests", "*.tests.*", "*benchmarks*"]),
entry_points="""
[console_scripts]
pio=pioreactor.command_line_worker:pio
pios=pioreactor.command_line_leader:pios
pio=pioreactor.pio_cli:pio
pios=pioreactor.pios_cli:pios
""",
)

0 comments on commit f5c8f61

Please sign in to comment.