Skip to content
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
27 changes: 21 additions & 6 deletions aixplain/cli_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,43 @@
CLI Runner
"""
import click
from aixplain.factories.cli.model_factory_cli import list_host_machines, list_functions, create_asset_repo, asset_repo_login, onboard_model, deploy_huggingface_model, get_huggingface_model_status, list_gpus
from aixplain.factories.cli.model_factory_cli import (
list_host_machines,
list_functions,
create_asset_repo,
asset_repo_login,
onboard_model,
deploy_huggingface_model,
get_huggingface_model_status,
list_gpus,
)

@click.group('cli')

@click.group("cli")
def cli():
pass

@click.group('list')

@click.group("list")
def list():
pass

@click.group('get')

@click.group("get")
def get():
pass

@click.group('create')

@click.group("create")
def create():
pass

@click.group('onboard')

@click.group("onboard")
def onboard():
pass


cli.add_command(list)
cli.add_command(get)
cli.add_command(create)
Expand Down
1 change: 1 addition & 0 deletions aixplain/enums/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@
from .supplier import Supplier
from .sort_by import SortBy
from .sort_order import SortOrder
from .model_status import ModelStatus
33 changes: 17 additions & 16 deletions aixplain/enums/asset_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@
from enum import Enum
from typing import Text


class AssetStatus(Text, Enum):
HIDDEN = 'hidden'
SCHEDULED = 'scheduled'
ONBOARDING = 'onboarding'
ONBOARDED = 'onboarded'
PENDING = 'pending'
FAILED = 'failed'
TRAINING = 'training'
REJECTED = 'rejected'
ENABLING = 'enabling'
DELETING = 'deleting'
DISABLED = 'disabled'
DELETED = 'deleted'
IN_PROGRESS = 'in_progress'
COMPLETED = 'completed'
CANCELING = 'canceling'
CANCELED = 'canceled'
HIDDEN = "hidden"
SCHEDULED = "scheduled"
ONBOARDING = "onboarding"
ONBOARDED = "onboarded"
PENDING = "pending"
FAILED = "failed"
TRAINING = "training"
REJECTED = "rejected"
ENABLING = "enabling"
DELETING = "deleting"
DISABLED = "disabled"
DELETED = "deleted"
IN_PROGRESS = "in_progress"
COMPLETED = "completed"
CANCELING = "canceling"
CANCELED = "canceled"
2 changes: 1 addition & 1 deletion aixplain/enums/data_subtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ class DataSubtype(Enum):
RACE = "race"
SPLIT = "split"
TOPIC = "topic"

def __str__(self):
return self._value_
2 changes: 1 addition & 1 deletion aixplain/enums/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def load_functions():
if input_data_object["required"] is True
},
"output": {output_data_object["dataType"] for output_data_object in function["output"]},
"spec": function
"spec": function,
}
for function in resp["items"]
}
Expand Down
11 changes: 11 additions & 0 deletions aixplain/enums/model_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from enum import Enum
from typing import Text


class ModelStatus(Text, Enum):
FAILED = "FAILED"
IN_PROGRESS = "IN_PROGRESS"
SUCCESS = "SUCCESS"

def __str__(self):
return self._value_
2 changes: 1 addition & 1 deletion aixplain/enums/storage_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ class StorageType(Enum):
FILE = "file"

def __str__(self):
return self._value_
return self._value_
79 changes: 44 additions & 35 deletions aixplain/factories/cli/model_factory_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import click
import yaml


@click.command("hosts")
@click.option("--api-key", default=None,
help="TEAM_API_KEY if not already set in environment")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment")
def list_host_machines(api_key: Optional[Text] = None) -> None:
"""CLI wrapper function for the LIST_HOST_MACHINES function in
"""CLI wrapper function for the LIST_HOST_MACHINES function in
ModelFactory.

Args:
Expand All @@ -43,16 +43,15 @@ def list_host_machines(api_key: Optional[Text] = None) -> None:
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("functions")
@click.option("--verbose", is_flag=True,
help="List all function details, False by default.")
@click.option("--api-key", default=None,
help="TEAM_API_KEY if not already set in environment.")
@click.option("--verbose", is_flag=True, help="List all function details, False by default.")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
def list_functions(verbose: bool, api_key: Optional[Text] = None) -> None:
"""CLI wrapper function for the LIST_FUNCTIONS function in ModelFactory.

Args:
verbose (Boolean, optional): Set to True if a detailed response
verbose (Boolean, optional): Set to True if a detailed response
is desired; is otherwise False by default.
api_key (Text, optional): Team API key. Defaults to None.
Returns:
Expand All @@ -62,9 +61,9 @@ def list_functions(verbose: bool, api_key: Optional[Text] = None) -> None:
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("gpus")
@click.option("--api-key", default=None,
help="TEAM_API_KEY if not already set in environment.")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
def list_gpus(api_key: Optional[Text] = None) -> None:
"""CLI wrapper function for the LIST_GPUS function in ModelFactory.

Expand All @@ -77,22 +76,28 @@ def list_gpus(api_key: Optional[Text] = None) -> None:
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("image-repo")
@click.option("--name", help="Model name.")
@click.option("--description", help="Description of model.")
@click.option("--function", help="Function name obtained from LIST_FUNCTIONS.")
@click.option("--source-language", default="en",
help="Model source language in 2-character 639-1 code or 3-character 639-3 code.")
@click.option(
"--source-language", default="en", help="Model source language in 2-character 639-1 code or 3-character 639-3 code."
)
@click.option("--input-modality", help="Input type (text, video, image, etc.)")
@click.option("--output-modality", help="Output type (text, video, image, etc.)")
@click.option("--documentation-url", default="", help="Link to model documentation.")
@click.option("--api-key", default=None,
help="TEAM_API_KEY if not already set in environment.")
def create_asset_repo(name: Text, description: Text, function: Text,
source_language: Text, input_modality: Text,
output_modality: Text,
documentation_url: Optional[Text] = "",
api_key: Optional[Text] = None) -> None:
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
def create_asset_repo(
name: Text,
description: Text,
function: Text,
source_language: Text,
input_modality: Text,
output_modality: Text,
documentation_url: Optional[Text] = "",
api_key: Optional[Text] = None,
) -> None:
"""CLI wrapper function for the CREATE_ASSET_REPO function in ModelFactory.

Args:
Expand All @@ -109,16 +114,15 @@ def create_asset_repo(name: Text, description: Text, function: Text,
Returns:
None
"""
ret_val = ModelFactory.create_asset_repo(name, description, function,
source_language, input_modality,
output_modality, documentation_url,
api_key)
ret_val = ModelFactory.create_asset_repo(
name, description, function, source_language, input_modality, output_modality, documentation_url, api_key
)
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("image-repo-login")
@click.option("--api-key", default=None,
help="TEAM_API_KEY if not already set in environment.")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
def asset_repo_login(api_key: Optional[Text] = None) -> None:
"""CLI wrapper function for the ASSET_REPO_LOGIN function in ModelFactory.

Expand All @@ -132,15 +136,16 @@ def asset_repo_login(api_key: Optional[Text] = None) -> None:
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("model")
@click.option("--model-id", help="Model ID from CREATE_IMAGE_REPO.")
@click.option("--image-tag", help="The tag of the image that you would like hosted.")
@click.option("--image-hash", help="The hash of the image you would like onboarded.")
@click.option("--host-machine", default="", help="The machine on which to host the model.")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
def onboard_model(model_id: Text, image_tag: Text, image_hash: Text,
host_machine: Optional[Text] = "",
api_key: Optional[Text] = None) -> None:
def onboard_model(
model_id: Text, image_tag: Text, image_hash: Text, host_machine: Optional[Text] = "", api_key: Optional[Text] = None
) -> None:
"""CLI wrapper function for the ONBOARD_MODEL function in ModelFactory.

Args:
Expand All @@ -150,22 +155,25 @@ def onboard_model(model_id: Text, image_tag: Text, image_hash: Text,

Returns:
None
"""
ret_val = ModelFactory.onboard_model(model_id, image_tag, image_hash,
host_machine, api_key)
"""
ret_val = ModelFactory.onboard_model(model_id, image_tag, image_hash, host_machine, api_key)
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("hf-model")
@click.option("--name", help="User-defined name for Hugging Face model.")
@click.option("--hf-repo-id", help="Repository ID from Hugging Face in {supplier}/{model name} form.")
@click.option("--revision", default="", help="Commit hash of repository.")
@click.option("--hf-token", default=None, help="Hugging Face token used to authenticate to this model.")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
def deploy_huggingface_model(name: Text, hf_repo_id: Text,
hf_token: Optional[Text] = None,
revision: Optional[Text] = None,
api_key: Optional[Text] = None) -> None:
def deploy_huggingface_model(
name: Text,
hf_repo_id: Text,
hf_token: Optional[Text] = None,
revision: Optional[Text] = None,
api_key: Optional[Text] = None,
) -> None:
"""CLI wrapper function for the DEPLOY_HUGGINGFACE_MODEL function in ModelFactory.

Args:
Expand All @@ -179,6 +187,7 @@ def deploy_huggingface_model(name: Text, hf_repo_id: Text,
ret_val_yaml = yaml.dump(ret_val)
click.echo(ret_val_yaml)


@click.command("hf-model-status")
@click.option("--model-id", help="Model ID from DEPLOY_HUGGINGFACE_MODEL.")
@click.option("--api-key", default=None, help="TEAM_API_KEY if not already set in environment.")
Expand Down
2 changes: 1 addition & 1 deletion aixplain/factories/file_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ def create(
"""
assert (
license is not None if is_temp is False else True
), "File Asset Creation Error: To upload a non-temporary file, you need to specify the `license`."
), "File Asset Creation Error: To upload a non-temporary file, you need to specify the `license`."
return cls.upload(local_path=local_path, tags=tags, license=license, is_temp=is_temp)
4 changes: 2 additions & 2 deletions aixplain/factories/finetune_factory/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def create(
assert (
train_percentage + dev_percentage <= 100
), f"Create FineTune: Train percentage + dev percentage ({train_percentage + dev_percentage}) must be less than or equal to one"

for i, dataset in enumerate(dataset_list):
if isinstance(dataset, str) is True:
dataset_list[i] = DatasetFactory.get(dataset_id=dataset)

if isinstance(model, str) is True:
model = ModelFactory.get(model_id=model)

Expand Down
4 changes: 2 additions & 2 deletions aixplain/factories/wallet_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class WalletFactory:
backend_url = config.BACKEND_URL

@classmethod
def get(cls, api_key: Text = config.TEAM_API_KEY) -> Wallet:
def get(cls, api_key: Text = config.TEAM_API_KEY) -> Wallet:
"""Get wallet information"""
try:
resp = None
Expand All @@ -22,7 +22,7 @@ def get(cls, api_key: Text = config.TEAM_API_KEY) -> Wallet:
resp = r.json()
total_balance = float(resp.get("totalBalance", 0.0))
reserved_balance = float(resp.get("reservedBalance", 0.0))

return Wallet(total_balance=total_balance, reserved_balance=reserved_balance)
except Exception as e:
raise Exception(f"Failed to get the wallet credit information. Error: {str(e)}")
5 changes: 2 additions & 3 deletions aixplain/modules/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
description: Text = "",
supplier: Text = "aiXplain",
version: Text = "1.0",
**additional_info
**additional_info,
) -> None:
"""Create a Benchmark with the necessary information.

Expand Down Expand Up @@ -84,7 +84,6 @@ def __init__(
def __repr__(self) -> str:
return f"<Benchmark {self.name}>"


def start(self) -> BenchmarkJob:
"""Starts a new benchmark job(run) for the current benchmark

Expand All @@ -104,4 +103,4 @@ def start(self) -> BenchmarkJob:
except Exception as e:
error_message = f"Starting Benchmark Job: Error in Creating Benchmark {benhchmark_id} : {e}"
logging.error(error_message, exc_info=True)
return None
return None
Loading