project
TOC
- Attributes:
- 🅰 CONFIG_FILE_NAME - later will be overwrite by workspace config file
- 🅰 NEETBOX_VERSION - later will be overwrite by workspace config file
- 🅰 _DEFAULT_WORKSPACE_CONFIG - later will be overwrite by workspace config file
- 🅰 _QUERY_ADD_EXTENSION_DEFAULT_CONFIG - if workspace already loaded
- 🅰 _IS_WORKSPACE_LOADED - if workspace already loaded
- 🅰 _QUERY_AFTER_CONFIG_LOAD - if workspace already loaded
- Functions:
- 🅵 _obtain_new_run_id - put a new run id into config. do not run before workspace loaded as a project.
- 🅵 on_config_loaded
- 🅵 export_default_config
- 🅵 _build_global_config_dict_for_module - build a global config from a local config of a module. for example:
- 🅵 _update_default_config_from_config_register - iterate through config register to read their default config and write the result into global config. DO NOT run after workspace loaded.
- 🅵 _update_default_workspace_config_with
- 🅵 _init_workspace
- 🅵 _load_workspace_config
- 🅵 _create_load_workspace
- 🅵 _get_module_level_config - get a module level config from global config
Attributes
🅰 CONFIG_FILE_NAME
CONFIG_FILE_NAME = f"""neetbox.toml""" #later will be overwrite by workspace config file
🅰 NEETBOX_VERSION
NEETBOX_VERSION = version("neetbox") #later will be overwrite by workspace config file
🅰 _DEFAULT_WORKSPACE_CONFIG
_DEFAULT_WORKSPACE_CONFIG = {
NAME_KEY: os.path.basename(os.path.normpath(os.getcwd())),
"version": NEETBOX_VERSION,
PROJECT_ID_KEY: str(uuid4()),
"extension": {"autoload": True},
"client": {
"enable": True,
"host": "127.0.0.1",
"port": 20202,
"allowIpython": False,
"mute": True,
"mode": "detached",
"uploadInterval": 1,
"shell": {"enable": True, "daemon": True},
},
} #later will be overwrite by workspace config file
🅰 _QUERY_ADD_EXTENSION_DEFAULT_CONFIG
_QUERY_ADD_EXTENSION_DEFAULT_CONFIG = [] #if workspace already loaded
🅰 _IS_WORKSPACE_LOADED
_IS_WORKSPACE_LOADED = False #if workspace already loaded
🅰 _QUERY_AFTER_CONFIG_LOAD
_QUERY_AFTER_CONFIG_LOAD = [] #if workspace already loaded
Functions
🅵 _obtain_new_run_id
def _obtain_new_run_id():
put a new run id into config. do not run before workspace loaded as a project.
Returns:
- str: new run id
🅵 on_config_loaded
def on_config_loaded(func):
🅵 export_default_config
def export_default_config(func):
🅵 _build_global_config_dict_for_module
def _build_global_config_dict_for_module(module, local_config):
build a global config from a local config of a module. for example:
- local config in neetbox/moduleA/some.py: { { "a" : 1 } }
- the returned global config: { moduleA: { some: { "a" : 1 } } }
Parameters:
- module (type): _description_
- local_config (type): _description_
🅵 _update_default_config_from_config_register
def _update_default_config_from_config_register():
iterate through config register to read their default config and write the result into global config. DO NOT run after workspace loaded.
Raises:
- e: any possible exception
🅵 _update_default_workspace_config_with
def _update_default_workspace_config_with(cfg: dict):
🅵 _init_workspace
def _init_workspace(path=None, **kwargs) -> bool:
🅵 _load_workspace_config
def _load_workspace_config(folder=".", load_only=False):
🅵 _create_load_workspace
def _create_load_workspace(folder="."):
🅵 _get_module_level_config
def _get_module_level_config(
module: Union[str, types.ModuleType] = None, **kwargs
):
get a module level config from global config
Parameters:
- module (str or module) (default to
None(which means neetbox will automatically find the module in which this function is called). if you want to get all the global config, pass "@" for module
): which module's config to get. Defaults to None(which means neetbox will automatically find the module in which this function is called). if you want to get all the global config, pass "@" for module.
Returns:
- dict: the config you want.