forked from phoenix-oss/llama-stack-mirror
Rename the "package" word away
This commit is contained in:
parent
98c55b63b4
commit
a36699cd11
3 changed files with 13 additions and 17 deletions
|
@ -102,8 +102,8 @@ class StackConfigure(Subcommand):
|
||||||
if output_dir:
|
if output_dir:
|
||||||
builds_dir = Path(output_dir)
|
builds_dir = Path(output_dir)
|
||||||
os.makedirs(builds_dir, exist_ok=True)
|
os.makedirs(builds_dir, exist_ok=True)
|
||||||
package_name = build_config.name.replace("::", "-")
|
image_name = build_config.name.replace("::", "-")
|
||||||
package_file = builds_dir / f"{package_name}-run.yaml"
|
run_config_file = builds_dir / f"{image_name}-run.yaml"
|
||||||
|
|
||||||
api2providers = build_config.distribution_spec.providers
|
api2providers = build_config.distribution_spec.providers
|
||||||
|
|
||||||
|
@ -112,31 +112,31 @@ class StackConfigure(Subcommand):
|
||||||
for api_str, provider in api2providers.items()
|
for api_str, provider in api2providers.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
if package_file.exists():
|
if run_config_file.exists():
|
||||||
cprint(
|
cprint(
|
||||||
f"Configuration already exists for {build_config.name}. Will overwrite...",
|
f"Configuration already exists for {build_config.name}. Will overwrite...",
|
||||||
"yellow",
|
"yellow",
|
||||||
attrs=["bold"],
|
attrs=["bold"],
|
||||||
)
|
)
|
||||||
config = PackageConfig(**yaml.safe_load(package_file.read_text()))
|
config = StackRunConfig(**yaml.safe_load(run_config_file.read_text()))
|
||||||
else:
|
else:
|
||||||
config = PackageConfig(
|
config = StackRunConfig(
|
||||||
built_at=datetime.now(),
|
built_at=datetime.now(),
|
||||||
package_name=package_name,
|
image_name=image_name,
|
||||||
providers=stub_config,
|
providers=stub_config,
|
||||||
)
|
)
|
||||||
|
|
||||||
config.providers = configure_api_providers(config.providers)
|
config.providers = configure_api_providers(config.providers)
|
||||||
config.docker_image = (
|
config.docker_image = (
|
||||||
package_name if build_config.image_type == "docker" else None
|
image_name if build_config.image_type == "docker" else None
|
||||||
)
|
)
|
||||||
config.conda_env = package_name if build_config.image_type == "conda" else None
|
config.conda_env = image_name if build_config.image_type == "conda" else None
|
||||||
|
|
||||||
with open(package_file, "w") as f:
|
with open(run_config_file, "w") as f:
|
||||||
to_write = json.loads(json.dumps(config.dict(), cls=EnumEncoder))
|
to_write = json.loads(json.dumps(config.dict(), cls=EnumEncoder))
|
||||||
f.write(yaml.dump(to_write, sort_keys=False))
|
f.write(yaml.dump(to_write, sort_keys=False))
|
||||||
|
|
||||||
cprint(
|
cprint(
|
||||||
f"> YAML configuration has been written to {package_file}",
|
f"> YAML configuration has been written to {run_config_file}",
|
||||||
color="blue",
|
color="blue",
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,7 +13,6 @@ import yaml
|
||||||
|
|
||||||
from llama_toolchain.cli.subcommand import Subcommand
|
from llama_toolchain.cli.subcommand import Subcommand
|
||||||
from llama_toolchain.core.datatypes import * # noqa: F403
|
from llama_toolchain.core.datatypes import * # noqa: F403
|
||||||
from llama_toolchain.common.config_dirs import BUILDS_BASE_DIR
|
|
||||||
|
|
||||||
|
|
||||||
class StackRun(Subcommand):
|
class StackRun(Subcommand):
|
||||||
|
@ -29,8 +28,6 @@ class StackRun(Subcommand):
|
||||||
self.parser.set_defaults(func=self._run_stack_run_cmd)
|
self.parser.set_defaults(func=self._run_stack_run_cmd)
|
||||||
|
|
||||||
def _add_arguments(self):
|
def _add_arguments(self):
|
||||||
from llama_toolchain.core.package import ImageType
|
|
||||||
|
|
||||||
self.parser.add_argument(
|
self.parser.add_argument(
|
||||||
"config",
|
"config",
|
||||||
type=str,
|
type=str,
|
||||||
|
@ -51,7 +48,6 @@ class StackRun(Subcommand):
|
||||||
|
|
||||||
def _run_stack_run_cmd(self, args: argparse.Namespace) -> None:
|
def _run_stack_run_cmd(self, args: argparse.Namespace) -> None:
|
||||||
from llama_toolchain.common.exec import run_with_pty
|
from llama_toolchain.common.exec import run_with_pty
|
||||||
from llama_toolchain.core.package import ImageType
|
|
||||||
|
|
||||||
if not args.config:
|
if not args.config:
|
||||||
self.parser.error("Must specify a config file to run")
|
self.parser.error("Must specify a config file to run")
|
||||||
|
@ -67,7 +63,7 @@ class StackRun(Subcommand):
|
||||||
return
|
return
|
||||||
|
|
||||||
with open(config_file, "r") as f:
|
with open(config_file, "r") as f:
|
||||||
config = PackageConfig(**yaml.safe_load(f))
|
config = StackRunConfig(**yaml.safe_load(f))
|
||||||
|
|
||||||
if config.docker_image:
|
if config.docker_image:
|
||||||
script = pkg_resources.resource_filename(
|
script = pkg_resources.resource_filename(
|
||||||
|
|
|
@ -163,10 +163,10 @@ class DistributionSpec(BaseModel):
|
||||||
|
|
||||||
|
|
||||||
@json_schema_type
|
@json_schema_type
|
||||||
class PackageConfig(BaseModel):
|
class StackRunConfig(BaseModel):
|
||||||
built_at: datetime
|
built_at: datetime
|
||||||
|
|
||||||
package_name: str = Field(
|
image_name: str = Field(
|
||||||
...,
|
...,
|
||||||
description="""
|
description="""
|
||||||
Reference to the distribution this package refers to. For unregistered (adhoc) packages,
|
Reference to the distribution this package refers to. For unregistered (adhoc) packages,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue