From 188aef8fa24696dfa67390f218c6882aa51ae852 Mon Sep 17 00:00:00 2001 From: Yuan Tang Date: Sat, 21 Dec 2024 12:06:17 -0500 Subject: [PATCH] Fix lint Signed-off-by: Yuan Tang --- llama_stack/cli/stack/build.py | 11 +++++------ llama_stack/cli/stack/run.py | 1 + llama_stack/distribution/build.py | 2 +- llama_stack/distribution/stack.py | 3 +-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/llama_stack/cli/stack/build.py b/llama_stack/cli/stack/build.py index 3e49a583e..76766a0bd 100644 --- a/llama_stack/cli/stack/build.py +++ b/llama_stack/cli/stack/build.py @@ -293,13 +293,12 @@ class StackBuild(Subcommand): if template_name: # copy run.yaml from template to build_dir instead of generating it again - template_path = pkg_resources.resource_filename( - "llama_stack", f"templates/{template_name}/run.yaml" + template_path = ( + importlib.resources.files("llama_stack") + / f"templates/{template_name}/run.yaml" ) - os.makedirs(build_dir, exist_ok=True) - run_config_file = build_dir / f"{build_config.name}-run.yaml" - shutil.copy(template_path, run_config_file) - + with importlib.resources.as_file(template_path) as path: + shutil.copy(path, run_config_file) # Find all ${env.VARIABLE} patterns cprint("Build Successful!", color="green") else: diff --git a/llama_stack/cli/stack/run.py b/llama_stack/cli/stack/run.py index 3dee9eca1..0fbff709c 100644 --- a/llama_stack/cli/stack/run.py +++ b/llama_stack/cli/stack/run.py @@ -52,6 +52,7 @@ class StackRun(Subcommand): def _run_stack_run_cmd(self, args: argparse.Namespace) -> None: import importlib.resources + import yaml from llama_stack.distribution.build import ImageType diff --git a/llama_stack/distribution/build.py b/llama_stack/distribution/build.py index e1fa08c58..5a7dfba11 100644 --- a/llama_stack/distribution/build.py +++ b/llama_stack/distribution/build.py @@ -4,13 +4,13 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +import importlib.resources import logging from enum import Enum from pathlib import Path from typing import Dict, List -import importlib.resources from pydantic import BaseModel from termcolor import cprint diff --git a/llama_stack/distribution/stack.py b/llama_stack/distribution/stack.py index e5d6f4c03..af220edea 100644 --- a/llama_stack/distribution/stack.py +++ b/llama_stack/distribution/stack.py @@ -4,13 +4,12 @@ # This source code is licensed under the terms described in the LICENSE file in # the root directory of this source tree. +import importlib.resources import logging import os import re -from pathlib import Path from typing import Any, Dict, Optional -import importlib.resources import yaml from termcolor import colored