@@ -51,24 +51,8 @@ def write_configfile(config, config_path):
5151 config .write (configfile )
5252
5353
54- def create_workspace (workspace_name , p_loader = None ):
55- """
56- Create a new workspace with the given name.
57-
58- Args:
59- ----
60- workspace_name (str): The name of the workspace.
61-
62- Returns:
63- -------
64- None
65- """
66- if exists (path_join (WORKSPACE_DIR , workspace_name )):
67- print (f"[-] Workspace { workspace_name } already exists" )
68- else :
69- print (f"[*] Creating { workspace_name } workspace" )
70- mkdir (path_join (WORKSPACE_DIR , workspace_name ))
71-
54+ def init_protocol_dbs (workspace_name , p_loader = None ):
55+ """Check for each protocol if the database exists, if not create it."""
7256 if p_loader is None :
7357 p_loader = ProtocolLoader ()
7458 protocols = p_loader .get_protocols ()
@@ -93,6 +77,27 @@ def create_workspace(workspace_name, p_loader=None):
9377 conn .close ()
9478
9579
80+ def create_workspace (workspace_name , p_loader = None ):
81+ """
82+ Create a new workspace with the given name.
83+
84+ Args:
85+ ----
86+ workspace_name (str): The name of the workspace.
87+
88+ Returns:
89+ -------
90+ None
91+ """
92+ if exists (path_join (WORKSPACE_DIR , workspace_name )):
93+ print (f"[-] Workspace { workspace_name } already exists" )
94+ else :
95+ print (f"[*] Creating { workspace_name } workspace" )
96+ mkdir (path_join (WORKSPACE_DIR , workspace_name ))
97+
98+ init_protocol_dbs (workspace_name , p_loader )
99+
100+
96101def delete_workspace (workspace_name ):
97102 shutil .rmtree (path_join (WORKSPACE_DIR , workspace_name ))
98103 print (f"[*] Workspace { workspace_name } deleted" )
@@ -137,3 +142,7 @@ def db_execute(self, *args):
137142 res = self .sess .execute (* args )
138143 self .lock .release ()
139144 return res
145+
146+
147+ # Even if the default workspace exists, we still need to check if every protocol has a database (in case of a new protocol)
148+ init_protocol_dbs ("default" )
0 commit comments