Skip to content

Commit

Permalink
add check for model file before attempting to upload (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
TShapinsky committed Jun 28, 2024
1 parent 8e85b38 commit 396c755
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions alfalfa_client/alfalfa_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ****************************************************************************************************

import errno
import json
import os
from collections import OrderedDict
from datetime import datetime
from numbers import Number
from time import sleep, time
from typing import List, Union
from urllib.parse import urljoin
Expand Down Expand Up @@ -151,6 +151,8 @@ def upload_model(self, model_path: os.PathLike) -> ModelID:
:param model_path: path to model file or folder or list of paths
:returns: id of model"""
if not os.path.exists(model_path):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), model_path)
model_path = prepare_model(model_path)
filename = os.path.basename(model_path)

Expand Down Expand Up @@ -205,7 +207,7 @@ def submit(self, model_path: Union[str, List[str]], wait_for_status: bool = True
return run_id

@parallelize
def start(self, run_id: Union[RunID, List[RunID]], start_datetime: Union[Number, datetime], end_datetime: Union[Number, datetime], timescale: int = 5, external_clock: bool = False, realtime: bool = False, wait_for_status: bool = True):
def start(self, run_id: Union[RunID, List[RunID]], start_datetime: datetime, end_datetime: datetime, timescale: int = 5, external_clock: bool = False, realtime: bool = False, wait_for_status: bool = True):
"""Start one run from a model.
:param run_id: id of run or list of ids
Expand Down
2 changes: 1 addition & 1 deletion alfalfa_client/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def add_payload(self, payload):
self.payload = payload

def __str__(self) -> str:
if self.payload:
if hasattr(self, "payload"):
return super().__str__() + '\nAPI Payload: \n' + json.dumps(self.payload)
return super().__str__()

Expand Down

0 comments on commit 396c755

Please sign in to comment.