Skip to content

Commit

Permalink
new cluster.addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Nov 13, 2024
1 parent 904494b commit 100474c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
### Upcoming
- improvements to correlation self-tests
- you can add addresses to the (new) `[cluster.addresses]` section to specify IPs for pioreactors. Example:
```
[cluster.addresses]
leader_hostname=pio00
leader_address=10.42.0.1
pio01_address=10.42.0.2
pio02_address=10.42.0.3
```
Note that the leader is automatically added.

### 24.10.29

Expand Down
4 changes: 2 additions & 2 deletions pioreactor/background_jobs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,10 @@ def _setup_actions(self, msg: pt.MQTTMessage) -> None:
post_delay = self.get_from_config("post_delay_duration", cast=float, fallback=1.0)
pre_delay = self.get_from_config("pre_delay_duration", cast=float, fallback=1.5)

if post_delay <= 0.25:
if post_delay < 0.25:
self.logger.warning("For optimal OD readings, keep `post_delay_duration` more than 0.25 seconds.")

if pre_delay <= 0.25:
if pre_delay < 0.25:
self.logger.warning("For optimal OD readings, keep `pre_delay_duration` more than 0.25 seconds.")

def sneak_in(ads_interval, post_delay, pre_delay) -> None:
Expand Down
4 changes: 4 additions & 0 deletions pioreactor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def get_config() -> ConfigParserMod:
if "od_config.photodiode_channel" in config:
config["od_config.photodiode_channel_reverse"] = config.invert_section("od_config.photodiode_channel")

# add this for hostname resolution using config.ini, see pioreactor.utils.networking.resolve_to_address
leader_hostname = config["cluster.topology"]["leader_hostname"]
config["cluster.addresses"][f"{leader_hostname}_address"] = config["cluster.topology"]["leader_address"]

return config


Expand Down
7 changes: 6 additions & 1 deletion pioreactor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from threading import Thread
from typing import Generator

from pioreactor.config import config
from pioreactor.exc import RsyncError


Expand Down Expand Up @@ -146,7 +147,11 @@ def worker_hostnames(queue: Queue) -> None:
def resolve_to_address(hostname: str) -> str:
# TODO: make this more fleshed out: resolve to IP, etc.
# add_local assumes a working mDNS.
return add_local(hostname)
address_in_config = config.get("cluster.addresses", f"{hostname}_address", fallback=None)
if address_in_config is not None:
return address_in_config
else:
return add_local(hostname)


def add_local(hostname: str) -> str:
Expand Down
3 changes: 1 addition & 2 deletions pioreactor/utils/pwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ def dc(self, dc: pt.FloatBetween0and100) -> None:
if self._started:
try:
lgpio.tx_pwm(self._handle, self.pin, self.frequency, self.dc)
except lgpio.error as e:
print(e)
except lgpio.error:
pass

else:
Expand Down

0 comments on commit 100474c

Please sign in to comment.