kikocis/llama-stack public
Changesets · Branches · Tags · Compare
| Changeset | efac2a2f572ee0c0cacbce5a556e45cff5f0d4b57f886aeadd2bf5fa6df3d768 |
|---|---|
| Author | Ashwin Bharambe <ashwin@meta.com> · 2024-09-16 12:22 -07:00 |
| Committer | Ashwin Bharambe <ashwin@meta.com> · 2024-09-16 12:22 -07:00 |
| Parents | 4a9621947bfe |
3 files changed
modified llama_toolchain/cli/stack/configure.py +10 −10
| @@ -102,8 +102,8 @@ | ||
| 102 | 102 | if output_dir: |
| 103 | 103 | builds_dir = Path(output_dir) |
| 104 | 104 | os.makedirs(builds_dir, exist_ok=True) |
| 105 | - package_name = build_config.name.replace("::", "-") | |
| 106 | - package_file = builds_dir / f"{package_name}-run.yaml" | |
| 105 | + image_name = build_config.name.replace("::", "-") | |
| 106 | + run_config_file = builds_dir / f"{image_name}-run.yaml" | |
| 107 | 107 | |
| 108 | 108 | api2providers = build_config.distribution_spec.providers |
| 109 | 109 | |
| @@ -112,31 +112,31 @@ | ||
| 112 | 112 | for api_str, provider in api2providers.items() |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - if package_file.exists(): | |
| 115 | + if run_config_file.exists(): | |
| 116 | 116 | cprint( |
| 117 | 117 | f"Configuration already exists for {build_config.name}. Will overwrite...", |
| 118 | 118 | "yellow", |
| 119 | 119 | attrs=["bold"], |
| 120 | 120 | ) |
| 121 | - config = PackageConfig(**yaml.safe_load(package_file.read_text())) | |
| 121 | + config = StackRunConfig(**yaml.safe_load(run_config_file.read_text())) | |
| 122 | 122 | else: |
| 123 | - config = PackageConfig( | |
| 123 | + config = StackRunConfig( | |
| 124 | 124 | built_at=datetime.now(), |
| 125 | - package_name=package_name, | |
| 125 | + image_name=image_name, | |
| 126 | 126 | providers=stub_config, |
| 127 | 127 | ) |
| 128 | 128 | |
| 129 | 129 | config.providers = configure_api_providers(config.providers) |
| 130 | 130 | config.docker_image = ( |
| 131 | - package_name if build_config.image_type == "docker" else None | |
| 131 | + image_name if build_config.image_type == "docker" else None | |
| 132 | 132 | ) |
| 133 | - config.conda_env = package_name if build_config.image_type == "conda" else None | |
| 133 | + config.conda_env = image_name if build_config.image_type == "conda" else None | |
| 134 | 134 | |
| 135 | - with open(package_file, "w") as f: | |
| 135 | + with open(run_config_file, "w") as f: | |
| 136 | 136 | to_write = json.loads(json.dumps(config.dict(), cls=EnumEncoder)) |
| 137 | 137 | f.write(yaml.dump(to_write, sort_keys=False)) |
| 138 | 138 | |
| 139 | 139 | cprint( |
| 140 | - f"> YAML configuration has been written to {package_file}", | |
| 140 | + f"> YAML configuration has been written to {run_config_file}", | |
| 141 | 141 | color="blue", |
| 142 | 142 | ) |
modified llama_toolchain/cli/stack/run.py +1 −5
| @@ -13,7 +13,6 @@ | ||
| 13 | 13 | |
| 14 | 14 | from llama_toolchain.cli.subcommand import Subcommand |
| 15 | 15 | from llama_toolchain.core.datatypes import * # noqa: F403 |
| 16 | -from llama_toolchain.common.config_dirs import BUILDS_BASE_DIR | |
| 17 | 16 | |
| 18 | 17 | |
| 19 | 18 | class StackRun(Subcommand): |
| @@ -29,8 +28,6 @@ | ||
| 29 | 28 | self.parser.set_defaults(func=self._run_stack_run_cmd) |
| 30 | 29 | |
| 31 | 30 | def _add_arguments(self): |
| 32 | - from llama_toolchain.core.package import ImageType | |
| 33 | - | |
| 34 | 31 | self.parser.add_argument( |
| 35 | 32 | "config", |
| 36 | 33 | type=str, |
| @@ -51,7 +48,6 @@ | ||
| 51 | 48 | |
| 52 | 49 | def _run_stack_run_cmd(self, args: argparse.Namespace) -> None: |
| 53 | 50 | from llama_toolchain.common.exec import run_with_pty |
| 54 | - from llama_toolchain.core.package import ImageType | |
| 55 | 51 | |
| 56 | 52 | if not args.config: |
| 57 | 53 | self.parser.error("Must specify a config file to run") |
| @@ -67,7 +63,7 @@ | ||
| 67 | 63 | return |
| 68 | 64 | |
| 69 | 65 | with open(config_file, "r") as f: |
| 70 | - config = PackageConfig(**yaml.safe_load(f)) | |
| 66 | + config = StackRunConfig(**yaml.safe_load(f)) | |
| 71 | 67 | |
| 72 | 68 | if config.docker_image: |
| 73 | 69 | script = pkg_resources.resource_filename( |
modified llama_toolchain/core/datatypes.py +2 −2
| @@ -163,10 +163,10 @@ | ||
| 163 | 163 | |
| 164 | 164 | |
| 165 | 165 | @json_schema_type |
| 166 | -class PackageConfig(BaseModel): | |
| 166 | +class StackRunConfig(BaseModel): | |
| 167 | 167 | built_at: datetime |
| 168 | 168 | |
| 169 | - package_name: str = Field( | |
| 169 | + image_name: str = Field( | |
| 170 | 170 | ..., |
| 171 | 171 | description=""" |
| 172 | 172 | Reference to the distribution this package refers to. For unregistered (adhoc) packages, |