Skip to content

Commit

Permalink
Update build_config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SireInsectus committed Nov 25, 2023
1 parent d546d0a commit a1969e3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/dbacademy/dbbuild/build_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ def libraries(self) -> List[Dict[str, Any]]:
def client(self) -> DBAcademyRestClient:
return self.__client

def initialize_notebooks(self, notebook_configs: Optional[Union[NotebookConfig, Dict[str, Any]]]) -> None:
def initialize_notebooks(self, notebook_configs: Optional[Union[NotebookConfig, List[NotebookConfig], Dict[str, Any]]], *and_configs: NotebookConfig) -> None:

from dbacademy.dbbuild.publish.notebook_def import NotebookDef
from dbacademy.dbhelper import dbh_constants

Expand Down Expand Up @@ -453,15 +454,24 @@ def initialize_notebooks(self, notebook_configs: Optional[Union[NotebookConfig,
if has_wip:
print()

if isinstance(notebook_configs, dict):
# def initialize_notebooks(self, notebook_configs: Optional[Union[NotebookConfig, Dict[str, Any]]], *and_configs: NotebookConfig) -> None:
if notebook_configs is None:
notebook_configs = list()

elif isinstance(notebook_configs, NotebookConfig):
# Convert the single instance of NotebookConfig into a list of NotebookConfigs
notebook_configs = list[notebook_configs]

elif isinstance(notebook_configs, dict):
# Convert the deprecated dictionary of notebook configurations to NotebookConfig objects.
dict_notebook_configs = list()
for name, arguments in notebook_configs.items():
dict_notebook_configs.append(NotebookConfig(name=name, **arguments))
# Replace the parameter with the list of NotebookConfig objects
notebook_configs = dict_notebook_configs

notebook_configs = validate(notebook_configs=notebook_configs).list(NotebookConfig, auto_create=True)
notebook_configs.extend(and_configs)
notebook_configs = validate(notebook_configs=notebook_configs).required.list(NotebookConfig)

for notebook_config in notebook_configs:
assert notebook_config.name in self.notebooks, f"""The notebook "{notebook_config.name}" was not found; double check the name in your set of notebook configurations passed to BuildConfig."""
Expand Down

0 comments on commit a1969e3

Please sign in to comment.