Skip to content

Commit 6b82ca8

Browse files
some small updates
1 parent e748a4f commit 6b82ca8

File tree

18 files changed

+137
-97
lines changed

18 files changed

+137
-97
lines changed

core/pioreactor/background_jobs/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def check_for_correct_permissions(self) -> None:
295295
for file in [
296296
storage_path / "pioreactor.sqlite",
297297
]:
298-
if file.exists() and (file.owner() != "pioreactor" or file.group() != "www-data"):
298+
if file.is_file() and (file.owner() != "pioreactor" or file.group() != "www-data"):
299299
self.logger.warning(
300300
f"Pioreactor sqlite database file {file} has the wrong permissions or does not exist."
301301
)

core/pioreactor/calibrations/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def load_active_calibration(device: Device) -> structs.AnyCalibration | None:
5454
def load_calibration(device: Device, calibration_name: str) -> structs.AnyCalibration:
5555
target_file = CALIBRATION_PATH / device / f"{calibration_name}.yaml"
5656

57-
if not target_file.exists():
57+
if not target_file.is_file():
5858
raise FileNotFoundError(
5959
f"Calibration {calibration_name} was not found in {CALIBRATION_PATH / device}"
6060
)
@@ -70,14 +70,14 @@ def load_calibration(device: Device, calibration_name: str) -> structs.AnyCalibr
7070

7171
def list_of_calibrations_by_device(device: Device) -> list[str]:
7272
device_dir = CALIBRATION_PATH / device
73-
if not device_dir.exists():
73+
if not device_dir.is_dir():
7474
return []
7575
return [file.stem for file in device_dir.glob("*.yaml")]
7676

7777

7878
def list_devices() -> list[str]:
7979
calibration_dir = CALIBRATION_PATH
80-
if not calibration_dir.exists():
80+
if not calibration_dir.is_dir():
8181
return []
8282

8383
return [f.name for f in calibration_dir.iterdir() if f.is_dir()]

core/pioreactor/calibrations/protocols/stirring_dc_based.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class RunCalibration(SessionStep):
214214
def render(self, ctx: SessionContext) -> CalibrationStep:
215215
return steps.action(
216216
"Record calibration",
217-
"Press Continue to run the stirring calibration. This will take a ~1 minute.",
217+
"Press Continue to run the stirring calibration. This will take up to one minute.",
218218
)
219219

220220
def advance(self, ctx: SessionContext) -> SessionStep | None:

core/pioreactor/cli/calibrations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def list_calibrations(device: str | None) -> None:
5353

5454
def _display_calibrations_by_device(device: str) -> None:
5555
calibration_dir = CALIBRATION_PATH / device
56-
if not calibration_dir.exists():
56+
if not calibration_dir.is_dir():
5757
click.echo(
5858
f"No calibrations found for device '{device}'. Directory does not exist.",
5959
err=True,
@@ -263,7 +263,7 @@ def delete_calibration(device: str, calibration_name: str) -> None:
263263
"""
264264
target_file = CALIBRATION_PATH / device / f"{calibration_name}.yaml"
265265

266-
if not target_file.exists():
266+
if not target_file.is_file():
267267
click.echo(f"No such calibration file: {target_file}")
268268
raise click.Abort()
269269

@@ -291,7 +291,7 @@ def analyze_calibration(device: str, calibration_name: str, fit: str) -> None:
291291
Analyze a calibration file from local storage.
292292
"""
293293
target_file = CALIBRATION_PATH / device / f"{calibration_name}.yaml"
294-
if not target_file.exists():
294+
if not target_file.is_file():
295295
click.echo(f"No such calibration file: {target_file}")
296296
raise click.Abort()
297297

core/pioreactor/cli/estimators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def list_estimators(device: str | None) -> None:
5454

5555
def _display_estimators_by_device(device: str) -> None:
5656
estimator_dir = ESTIMATOR_PATH / device
57-
if not estimator_dir.exists():
57+
if not estimator_dir.is_dir():
5858
click.echo(
5959
f"No estimators found for device '{device}'. Directory does not exist.",
6060
err=True,
@@ -136,7 +136,7 @@ def delete_estimator(device: str, estimator_name: str) -> None:
136136
"""
137137
target_file = ESTIMATOR_PATH / device / f"{estimator_name}.yaml"
138138

139-
if not target_file.exists():
139+
if not target_file.is_file():
140140
click.echo(f"No such estimator file: {target_file}")
141141
raise click.Abort()
142142

@@ -205,7 +205,7 @@ def analyze_estimator(device: str, estimator_name: str, fit: str) -> None:
205205
Analyze an estimator file from local storage.
206206
"""
207207
target_file = ESTIMATOR_PATH / device / f"{estimator_name}.yaml"
208-
if not target_file.exists():
208+
if not target_file.is_file():
209209
click.echo(f"No such estimator file: {target_file}", err=True)
210210
raise click.Abort()
211211

core/pioreactor/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def get_config() -> ConfigParserMod:
175175
else:
176176
local_config_path = "/home/pioreactor/.pioreactor/unit_config.ini"
177177

178-
if not Path(global_config_path).exists():
178+
if not Path(global_config_path).is_file():
179179
raise FileNotFoundError(
180180
f"Configuration file at {global_config_path} is missing. Has it completed initializing? Does it need to connect to a leader? Alternatively, use the env variable GLOBAL_CONFIG to specify its location."
181181
)

core/pioreactor/estimators/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def load_active_estimator(device: Device) -> structs.ODFusionEstimator | None:
3232

3333
def load_estimator(device: Device, estimator_name: str) -> structs.ODFusionEstimator:
3434
target_file = _estimator_path_for(device, estimator_name)
35-
if not target_file.exists():
35+
if not target_file.is_file():
3636
raise FileNotFoundError(f"Estimator {estimator_name} was not found in {ESTIMATOR_PATH / device}")
3737
if target_file.stat().st_size == 0:
3838
raise FileNotFoundError(f"Estimator {estimator_name} is empty")
@@ -45,12 +45,12 @@ def load_estimator(device: Device, estimator_name: str) -> structs.ODFusionEstim
4545

4646
def list_of_estimators_by_device(device: Device) -> list[str]:
4747
device_dir = ESTIMATOR_PATH / device
48-
if not device_dir.exists():
48+
if not device_dir.is_dir():
4949
return []
5050
return [file.stem for file in device_dir.glob("*.yaml")]
5151

5252

5353
def list_estimator_devices() -> list[str]:
54-
if not ESTIMATOR_PATH.exists():
54+
if not ESTIMATOR_PATH.is_dir():
5555
return []
5656
return [path.name for path in ESTIMATOR_PATH.iterdir() if path.is_dir()]

core/pioreactor/hardware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363

6464
def _load_yaml_if_exists(path: Path) -> dict[str, Any]:
65-
if path.exists():
65+
if path.is_file():
6666
try:
6767
return yaml_decode(path.read_bytes()) or {}
6868
except Exception as e:

core/pioreactor/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def load_contrib_model_definitions() -> list[Model]:
113113
MODEL_DEFINITIONS_PATH = Path(os.environ["DOT_PIOREACTOR"]) / "models"
114114

115115
models: list[Model] = []
116-
if not MODEL_DEFINITIONS_PATH.exists():
116+
if not MODEL_DEFINITIONS_PATH.is_dir():
117117
return models
118118
for file in MODEL_DEFINITIONS_PATH.glob("*.y*ml"):
119119
try:

core/pioreactor/structs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def exists_on_disk_for_device(self, device: str) -> bool:
261261

262262
target_file = CALIBRATION_PATH / device / f"{self.calibration_name}.yaml"
263263

264-
return target_file.exists()
264+
return target_file.is_file()
265265

266266
def x_to_y(self, x: X) -> Y:
267267
"""
@@ -427,7 +427,7 @@ def exists_on_disk_for_device(self, device: str) -> bool:
427427

428428
target_file = ESTIMATOR_PATH / device / f"{self.estimator_name}.yaml"
429429

430-
return target_file.exists()
430+
return target_file.is_file()
431431

432432
def is_active(self, device: str) -> bool:
433433
from pioreactor.utils import local_persistent_storage

0 commit comments

Comments
 (0)