Skip to content

Commit 62569ee

Browse files
authored
Merge pull request #459 from XpressAI/fahreza/backup-core
✨ Core Library Update CLI
2 parents fb0fcd5 + a687c90 commit 62569ee

5 files changed

Lines changed: 551 additions & 45 deletions

File tree

xircuits/library/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .list_library import list_component_library
22
from .install_fetch_library import install_library, fetch_library, uninstall_library
33
from .create_library import create_or_update_library
4-
from .update_library import update_library
4+
from .update_library import update_library
5+
from .core_libs import CORE_LIBS, is_core_library

xircuits/library/core_libs.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import FrozenSet
2+
3+
# Core component libraries that are bundled with the xircuits wheel
4+
CORE_LIBS: FrozenSet[str] = frozenset({
5+
"xai_controlflow",
6+
"xai_events",
7+
"xai_template",
8+
"xai_utils",
9+
})
10+
11+
def is_core_library(library_name: str) -> bool:
12+
"""Check if a library name refers to a core component."""
13+
normalized = library_name.strip().lower()
14+
if not normalized.startswith("xai_"):
15+
normalized = f"xai_{normalized}"
16+
return normalized in CORE_LIBS

xircuits/library/install_fetch_library.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import shutil
22
from pathlib import Path
33

4+
from .core_libs import is_core_library
5+
46
from xircuits.utils.file_utils import is_valid_url, is_empty
57
from xircuits.utils.requirements_utils import read_requirements_for_library
68
from xircuits.utils.git_toml_manager import (
@@ -19,10 +21,6 @@
1921
from ..handlers.request_remote import request_remote_library
2022
from ..handlers.request_folder import clone_from_github_url
2123

22-
23-
CORE_LIBS = {"xai_events", "xai_template", "xai_controlflow", "xai_utils"}
24-
25-
2624
def get_component_library_path(library_name: str) -> str:
2725
"""
2826
If a URL is provided, clone to xai_components/xai_<name>.
@@ -149,7 +147,7 @@ def uninstall_library(library_name: str) -> str:
149147
raw = "xai_" + raw
150148
short = raw.split("/")[-1]
151149

152-
if short in CORE_LIBS:
150+
if is_core_library(short):
153151
raise RuntimeError(f"'{short}' is a core library and cannot be uninstalled.")
154152

155153
lib_path = resolve_library_dir(short)

0 commit comments

Comments
 (0)