Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add check for model file before attempting to upload #65

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading