import nblite.config as this_module
config
ExportRule
Inherits from: BaseModel
CodeLocation
Inherits from: BaseModel
Methods
file_ext
self) -> str file_ext(
jupytext_format
self) -> str jupytext_format(
NBLiteConfig
Inherits from: BaseModel
Methods
init
__init__(self, **kwargs)
_has_cycle
-> bool _has_cycle(cls, rules: List[ExportRule])
_order_pipeline
-> List[ExportRule] _order_pipeline(cls, pipeline: List[ExportRule])
__post_process
self) __post_process(
= NBLiteConfig(
conf ="nbs",
docs_cl=[
export_pipeline="nbs", to_key="pts"),
ExportRule(from_key="pts", to_key="lib"),
ExportRule(from_key="test_nbs", to_key="test_pts"),
ExportRule(from_key="test_pts", to_key="test_lib"),
ExportRule(from_key
],={
code_locations"nbs": CodeLocation(path="nbs", format="ipynb"),
"pts": CodeLocation(path="pts", format="percent"),
"test_nbs": CodeLocation(path="test_nbs", format="ipynb"),
"test_pts": CodeLocation(path="test_pts", format="percent"),
"lib": CodeLocation(path="my_module", format="module"),
"test_lib": CodeLocation(path="test_module", format="module"),
} )
parse_config_dict
-> NBLiteConfig parse_config_dict(config_dict)
= '''
toml_string export_pipeline = """
#nbs->pts
pts ->lib
test_nbs-> test_pts, test_pts->test_lib
"""
docs_cl = "nbs"
[cl.lib]
path = "my_module"
format = "module"
[cl.test_lib]
path = "test"
[cl.nbs]
format = "ipynb"
[cl.pts]
format = "percent"
[cl.test]
format = "module"
[cl.test_nbs]
format = "ipynb"
[cl.test_pts]
'''
parse_config_dict(toml.loads(toml_string)).model_dump()
{'export_pipeline': [{'from_key': 'pts', 'to_key': 'lib'},
{'from_key': 'test_nbs', 'to_key': 'test_pts'},
{'from_key': 'test_pts', 'to_key': 'test_lib'}],
'code_locations': {'lib': {'path': 'my_module', 'format': 'module'},
'test_lib': {'path': 'test', 'format': 'module'},
'nbs': {'path': 'nbs', 'format': 'ipynb'},
'pts': {'path': 'pts', 'format': 'percent'},
'test': {'path': 'test', 'format': 'module'},
'test_nbs': {'path': 'test_nbs', 'format': 'ipynb'},
'test_pts': {'path': 'test_pts', 'format': 'percent'}},
'docs_cl': 'nbs',
'docs_title': None}
= '''
toml_string export_pipeline = """
pts ->lib
"""
docs_cl = "nbs"
'''
parse_config_dict(toml.loads(toml_string)).model_dump()
{'export_pipeline': [{'from_key': 'pts', 'to_key': 'lib'}],
'code_locations': {'pts': {'path': 'pts', 'format': 'percent'},
'lib': {'path': 'lib', 'format': 'module'}},
'docs_cl': 'nbs',
'docs_title': None}
'../../test_proj')).name _find_config_file(Path(
'nblite.toml'
read_config
-> NBLiteConfig read_config(path)
'../../test_proj/nblite.toml') read_config(
NBLiteConfig(export_pipeline=[ExportRule(from_key='nbs', to_key='pcts'), ExportRule(from_key='pcts', to_key='lgts'), ExportRule(from_key='lgts', to_key='lib')], code_locations={'lib': CodeLocation(path='my_module', format='module'), 'pcts': CodeLocation(path='pcts', format='percent'), 'lgts': CodeLocation(path='lgts', format='light'), 'nbs': CodeLocation(path='nbs', format='ipynb')}, docs_cl='pcts', docs_title='nblite')
get_project_root_and_config
None]) -> Path get_project_root_and_config(curr_folder: Union[Path,
= get_project_root_and_config('../../test_proj')
root_path, config Path(root_path).name
'test_proj'
get_top_level_code_locations
-> List[str] get_top_level_code_locations(config: NBLiteConfig)
Returns the top level code locations in the export pipeline.
= get_project_root_and_config('../../test_proj')
root_path, config get_top_level_code_locations(config)
['nbs']
= read_config('../../test_proj/nblite.toml')
config 'nbs') get_downstream_module(config,
'lib'