complete ai kerne frame code

This commit is contained in:
Liu Zhicong
2023-08-20 22:53:35 -07:00
parent 6b39379d7c
commit 814f5cf481
21 changed files with 725 additions and 20 deletions
@@ -0,0 +1,3 @@
from .env import pkg_env_mgr,pkg_env
from .pkg import pkg_info,pkg_media_info
from .installer import pkg_install_task
+4 -4
View File
@@ -19,7 +19,7 @@ INSTALL_TASK_STATE_DOWNLOADING = 3
INSTALL_TASK_STATE_INSTALLING = 4
INSTALL_TAKS_STATE_ERROR = 5
class install_task:
class pkg_install_task:
def __init__(self,owner:pkg_env) -> None:
self.owner = owner
self.state = INSTALL_TASK_STATE_CHECK_DEPENDENCY
@@ -35,7 +35,7 @@ class pkg_installer:
self.owner_env = owner_env
def install(self,pkg_name:str,
install_from_dependency = False, can_upgrade = True,skip_depends = False,options = None)->Tuple[install_task,str]:
install_from_dependency = False, can_upgrade = True,skip_depends = False,options = None)->Tuple[pkg_install_task,str]:
the_pkg_info : pkg_info = None
is_upgrade : bool = False
@@ -74,7 +74,7 @@ class pkg_installer:
return result_task,"already installing"
logger.info(f"start download&install {pkg_name},install_from_dependency={install_from_dependency},upgrade={is_upgrade},backup={need_backup},target_pkg_info={the_pkg_info}")
result_task = install_task()
result_task = pkg_install_task()
self.all_tasks[the_pkg_info.cid] = result_task
async def download_and_install_pkg()->int:
# check dependency
@@ -149,7 +149,7 @@ class pkg_installer:
if depend_task is not None:
logger.debug(f"{pkg.name}'s depend pkg {depend_pkg_name} already in task list")
continue
depend_task = install_task()
depend_task = pkg_install_task()
task_list[depend_pkg_name] = depend_task
depend_pkg_info = self.owner_env.lookup(depend_pkg_name)
@@ -0,0 +1,9 @@
class media_reader:
def __init__(self):
pass
def load_from_media(self,media_info:str) -> int:
pass
def read(self, inner_path:str):
raise NotImplementedError
+5 -4
View File
@@ -9,12 +9,13 @@ class pkg_info:
self.target_media_type = "dir"
self.source_media_type = "7z"
def parse_pkg_name(pkg_name:str) -> Tuple[str, str, str]:
#return pkg_id,version_str,cid
@classmethod
def parse_pkg_name(cls,pkg_name:str) -> Tuple[str, str, str]:
"""parse pkg name like test-pkg#nightly#>0.2.31#sha1:323423423 to test-pkg,nightly#>0.2.31,sha1:323423423"""
pass
@property
def cid(self) -> str:
return self.cid