Skip to content

Commit

Permalink
added raise error for JobStatus[nan]
Browse files Browse the repository at this point in the history
  • Loading branch information
mpvanderschelling committed Feb 7, 2025
1 parent 3f0e769 commit a3eb496
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/f3dasm/_src/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, file_path: str | Path, message: str = "File is empty"):
class DecodeError(Exception):
"""Exception raised when opening a file gives errors"""

def __init__(self, file_path: str | Path,
def __init__(self, file_path: str | Path = '',
message: str = "Error decoding file"):
"""
Initializes the EmptyFileError.
Expand All @@ -31,7 +31,7 @@ def __init__(self, file_path: str | Path,
file_path (str | Path): The path to faulty file.
message (str): A custom error message.
"""
self.file_path = Path(file_path) # Ensure it's a Path object
self.file_path = file_path # Ensure it's a Path object
self.message = f"{message}: {self.file_path}"
super().__init__(self.message)

Expand Down
10 changes: 9 additions & 1 deletion src/f3dasm/_src/experimentsample.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Local
from ._io import copy_object, load_object
from .design.domain import Domain
from .errors import DecodeError

# Authorship & Credits
# =============================================================================
Expand Down Expand Up @@ -90,7 +91,14 @@ def __init__(self, input_data: Optional[Dict[str, Any]] = None,
self._input_data = input_data
self._output_data = output_data
self.domain = domain
self.job_status = JobStatus[job_status]

try:
self.job_status = JobStatus[job_status]
# If nan is given as key, there is a problem with the decoding of
# the jobs.csv file
except KeyError:
raise DecodeError()

self.project_dir = project_dir

def __repr__(self):
Expand Down

0 comments on commit a3eb496

Please sign in to comment.