mirror of
https://github.com/NicolasBohn/NexQuant.git
synced 2026-07-27 23:47:46 +00:00
fix(security): replace remaining assert statements with proper error handling
Replaced 53 assert statements across 22 files with proper if/raise patterns (TypeError, ValueError, AssertionError) to resolve Bandit B101 alerts.
This commit is contained in:
@@ -620,7 +620,8 @@ class LocalEnv(Env[ASpecificLocalConf]):
|
||||
for lp, rp in running_extra_volume.items():
|
||||
volumes[lp] = rp
|
||||
|
||||
assert local_path is not None, "local_path should not be None"
|
||||
if local_path is None:
|
||||
raise ValueError("local_path should not be None")
|
||||
volumes = normalize_volumes(volumes, local_path)
|
||||
|
||||
@contextlib.contextmanager
|
||||
@@ -1472,7 +1473,8 @@ class DockerEnv(Env[DockerConf]):
|
||||
cpu_count=self.conf.cpu_count, # Set CPU limit
|
||||
**self._gpu_kwargs(client),
|
||||
)
|
||||
assert container is not None # Ensure container was created successfully
|
||||
if container is None:
|
||||
raise AssertionError("Docker container was not created successfully")
|
||||
logs = container.logs(stream=True)
|
||||
print(Rule("[bold green]Docker Logs Begin[/bold green]", style="dark_orange"))
|
||||
table = Table(title="Run Info", show_header=False)
|
||||
|
||||
@@ -84,7 +84,8 @@ class WorkflowTracker:
|
||||
# Log timer status if timer is started
|
||||
if self.loop_base.timer.started:
|
||||
remain_time = self.loop_base.timer.remain_time()
|
||||
assert remain_time is not None
|
||||
if remain_time is None:
|
||||
raise AssertionError("remain_time should not be None")
|
||||
mlflow.log_metric("remain_time", remain_time.total_seconds())
|
||||
mlflow.log_metric(
|
||||
"remain_percent",
|
||||
|
||||
Reference in New Issue
Block a user