Skip to content

Commit

Permalink
add exception for bad registry path
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldcampbelljr committed Jul 15, 2024
1 parent 70af18f commit 4b6771c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pipestat/backends/pephub_backend/pephubbackend.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import copy
import datetime
import operator
from logging import getLogger

import pephubclient
from pephubclient.constants import RegistryPath
from pephubclient.exceptions import ResponseError
from ubiquerg import parse_registry_path

from ...backends.abstract import PipestatBackend
from ...const import PKG_NAME, STATUS
from typing import List, Dict, Any, Optional, Union, NoReturn, Tuple, Literal
from typing import List, Dict, Any, Optional, Union, NoReturn, Literal


from pephubclient import PEPHubClient

from ...exceptions import UnrecognizedStatusError, RecordNotFoundError, ColumnNotFoundError
from ...exceptions import UnrecognizedStatusError, RecordNotFoundError, PipestatPEPHubError

_LOGGER = getLogger(PKG_NAME)

Expand Down Expand Up @@ -58,7 +55,7 @@ def __init__(
)

else:
raise Exception
raise PipestatPEPHubError(msg=f"Registry path to PEP is invalid: {pephub_path}")

def check_record_exists(
self,
Expand Down
8 changes: 8 additions & 0 deletions pipestat/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"PipestatDependencyError",
"ColumnNotFoundError",
"SchemaValidationErrorDuringReport",
"PipestatPEPHubError",
]


Expand Down Expand Up @@ -123,6 +124,13 @@ def __init__(self, msg):
super(PipestatDatabaseError, self).__init__(msg)


class PipestatPEPHubError(PipestatError):
"""PEPHub backend error"""

def __init__(self, msg):
super(PipestatPEPHubError, self).__init__(msg)


class InvalidTypeError(PipestatError):
"""Type of the reported value is not supported"""

Expand Down
10 changes: 10 additions & 0 deletions tests/test_pipestat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2691,3 +2691,13 @@ def test_pephub_unsupported_funcs(
psm.link("somedir")
psm.list_recent_results()
psm.summarize()

def test_pephub_unsupported_funcs(
self,
config_file_path,
schema_file_path,
results_file_path,
range_values,
):
with pytest.raises(PipestatPEPHubError):
psm = PipestatManager(pephub_path="bogus_path", schema_path=schema_file_path)

0 comments on commit 4b6771c

Please sign in to comment.