Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
add external to apply and default requirement type (#196)
Browse files Browse the repository at this point in the history
  • Loading branch information
mike0sv authored Apr 18, 2022
1 parent d5525e8 commit e8f10af
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mlem/api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def apply(
*data: Union[str, DatasetMeta, Any],
method: str = None,
output: str = None,
link: bool = False,
link: bool = None,
external: bool = None,
) -> Optional[Any]:
"""Apply provided model against provided data
Expand All @@ -67,6 +68,7 @@ def apply(
output (str, optional): If value is provided,
assume it's path and save output there.
link (bool): Whether to create a link to saved output in MLEM root folder.
external (bool): Whether to save result outside mlem dir
Returns:
If `output=None`, returns results for given data.
Expand All @@ -89,7 +91,7 @@ def apply(
return res[0]
return res
if len(res) == 1:
return save(res[0], output, link=link)
return save(res[0], output, external=external, link=link)

raise NotImplementedError(
"Saving several input data objects is not implemented yet"
Expand Down
3 changes: 3 additions & 0 deletions mlem/cli/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mlem.api import import_object
from mlem.cli.main import (
mlem_command,
option_external,
option_json,
option_link,
option_repo,
Expand Down Expand Up @@ -58,6 +59,7 @@ def apply(
help="Specify how to read data file for import", # f"Available types: {list_implementations(ImportHook)}"
),
link: bool = option_link,
external: bool = option_external,
json: bool = option_json,
):
"""Apply a model to a dataset. Resulting dataset will be saved as MLEM object to `output` if it is provided, otherwise will be printed
Expand Down Expand Up @@ -97,6 +99,7 @@ def apply(
method=method,
output=output,
link=link,
external=external,
)
if output is None and json:
print(
Expand Down
1 change: 1 addition & 0 deletions mlem/core/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Requirement(MlemObject):

class Config:
type_root = True
default_type = "installable"

abs_name: ClassVar[str] = "requirement"
type: ClassVar = ...
Expand Down

0 comments on commit e8f10af

Please sign in to comment.