Skip to content

Commit

Permalink
change log and ipv4
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Oct 2, 2023
1 parent 8faf76d commit 3b3ede7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
### Upcoming

- Fix OD calibration that would produce an extremely high value when the signal was below the minimum signal (the blank) during OD calibration.
- IPv4 is really IPv4 now.


### 23.9.20
The previous change:

> - Base automations now subclass from `pioreactor.automations.BaseAutomationJob`. You may need to change custom automation imports from, for example, `from pioreactor.automations import DosingAutomationJobContrib` to `from pioreactor.automations.dosing.base import DosingAutomationJobContrib`
had an import error that I didn't see in my testing. We changed this further to:

- Base automations now subclass from `pioreactor.automations.base.AutomationJob`.
- Fix bug on /updates page.
- Base automations now subclass from `pioreactor.automations.base.AutomationJob`.
- Fix bug on /updates page.

### 23.9.19
- When installing plugins, any leader-only commands would not be run. This is fixed.
Expand Down
4 changes: 2 additions & 2 deletions pioreactor/background_jobs/od_reading.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,15 +741,15 @@ def calibration(observed_voltage: pt.Voltage) -> pt.OD:

if not self.has_logged_warning:
self.logger.warning(
f"Signal below suggested calibration range. Calibrated for OD=[{min_OD:0.3g}, {max_OD:0.3g}], V=[{min_voltage:0.3g}, {max_voltage:0.3g}]. Observed {observed_voltage:0.3f}V."
f"Signal below suggested calibration range. Trimming signal. Calibrated for OD=[{min_OD:0.3g}, {max_OD:0.3g}], V=[{min_voltage:0.3g}, {max_voltage:0.3g}]. Observed {observed_voltage:0.3f}V."
)
self.has_logged_warning = True
return min_OD

else:
if not self.has_logged_warning:
self.logger.warning(
f"Signal outside suggested calibration range. Calibrated for OD=[{min_OD:0.3g}, {max_OD:0.3g}], V=[{min_voltage:0.3g}, {max_voltage:0.3g}]. Observed {observed_voltage:0.3f}V."
f"Signal outside suggested calibration range. Trimming signal. Calibrated for OD=[{min_OD:0.3g}, {max_OD:0.3g}], V=[{min_voltage:0.3g}, {max_voltage:0.3g}]. Observed {observed_voltage:0.3f}V."
)
self.has_logged_warning = True
return max_OD
Expand Down
30 changes: 16 additions & 14 deletions pioreactor/utils/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,22 @@ def is_connected_to_network() -> bool:


def get_ip() -> Optional[str]:
# TODO: is this always ipv4??
from psutil import net_if_addrs # type: ignore

# Check for IP address of wireless network interface 'wlan0'
try:
return net_if_addrs()["wlan0"][0].address
except Exception:
return None

# Check for IP address of ethernet network interface 'eth0'
try:
return net_if_addrs()["eth0"][0].address
except Exception:
pass
# returns ipv4
from psutil import net_if_addrs

interfaces = ["wlan0", "eth0"]

for iface in interfaces:
try:
ipv4_addresses = [
addr.address for addr in net_if_addrs()[iface] if addr.family == 2
] # AddressFamily.AF_INET == 2
if ipv4_addresses:
return ipv4_addresses[0]
except Exception:
continue

return None


def discover_workers_on_network(terminate: bool = False) -> Generator[str, None, None]:
Expand Down

0 comments on commit 3b3ede7

Please sign in to comment.