1717 print (f"Using default home directory: { HOME_DIR } " )
1818
1919# Context var for organization id (set by host app/session)
20- _current_org_id : contextvars .ContextVar [str | None ] = contextvars .ContextVar ("current_org_id" , default = None )
20+ _current_org_id : contextvars .ContextVar [str | None ] = contextvars .ContextVar (
21+ "current_org_id" , default = None
22+ )
2123
2224
2325def set_organization_id (organization_id : str | None ) -> None :
@@ -70,23 +72,27 @@ def get_workspace_dir() -> str:
7072 "TFL_HOME_DIR" , os .path .join (str (os .path .expanduser ("~" )), ".transformerlab" )
7173)
7274
75+
7376def get_experiments_dir () -> str :
7477 path = os .path .join (get_workspace_dir (), "experiments" )
7578 os .makedirs (name = path , exist_ok = True )
7679 return path
7780
81+
7882def get_jobs_dir () -> str :
7983 path = os .path .join (get_workspace_dir (), "jobs" )
8084 os .makedirs (name = path , exist_ok = True )
8185 return path
8286
83- # GLOBAL_LOG_PATH
84- # MTMIGRATE: This doesn't work in multi-tenant world
85- GLOBAL_LOG_PATH = os .path .join (get_workspace_dir (), "transformerlab.log" )
8687
87- # OTHER LOGS DIR:
88- LOGS_DIR = os .path .join (HOME_DIR , "logs" )
89- os .makedirs (name = LOGS_DIR , exist_ok = True )
88+ def get_global_log_path () -> str :
89+ return os .path .join (get_workspace_dir (), "transformerlab.log" )
90+
91+
92+ def get_logs_dir () -> str :
93+ path = os .path .join (HOME_DIR , "logs" )
94+ os .makedirs (name = path , exist_ok = True )
95+ return path
9096
9197
9298# TODO: Move this to Experiment
@@ -95,47 +101,66 @@ def experiment_dir_by_name(experiment_name: str) -> str:
95101 return os .path .join (experiments_dir , experiment_name )
96102
97103
98- PLUGIN_DIR = os .path .join (get_workspace_dir (), "plugins" )
104+ def get_plugin_dir () -> str :
105+ return os .path .join (get_workspace_dir (), "plugins" )
99106
100107
101108def plugin_dir_by_name (plugin_name : str ) -> str :
102109 plugin_name = secure_filename (plugin_name )
103- return os .path .join (PLUGIN_DIR , plugin_name )
110+ return os .path .join (get_plugin_dir () , plugin_name )
104111
105112
106- MODELS_DIR = os .path .join (get_workspace_dir (), "models" )
107- os .makedirs (name = MODELS_DIR , exist_ok = True )
113+ def get_models_dir () -> str :
114+ path = os .path .join (get_workspace_dir (), "models" )
115+ os .makedirs (name = path , exist_ok = True )
116+ return path
117+
108118
109- DATASETS_DIR = os .path .join (get_workspace_dir (), "datasets" )
110- os .makedirs (name = DATASETS_DIR , exist_ok = True )
119+ def get_datasets_dir () -> str :
120+ path = os .path .join (get_workspace_dir (), "datasets" )
121+ os .makedirs (name = path , exist_ok = True )
122+ return path
111123
112- # TASKS_DIR
113- TASKS_DIR = os .path .join (WORKSPACE_DIR , "tasks" )
114- os .makedirs (name = TASKS_DIR , exist_ok = True )
124+
125+ def get_tasks_dir () -> str :
126+ path = os .path .join (get_workspace_dir (), "tasks" )
127+ os .makedirs (name = path , exist_ok = True )
128+ return path
115129
116130
117131def dataset_dir_by_id (dataset_id : str ) -> str :
118- return os .path .join (DATASETS_DIR , dataset_id )
132+ return os .path .join (get_datasets_dir () , dataset_id )
119133
120134
121- TEMP_DIR = os .path .join (get_workspace_dir (), "temp" )
122- os .makedirs (name = TEMP_DIR , exist_ok = True )
135+ def get_temp_dir () -> str :
136+ path = os .path .join (get_workspace_dir (), "temp" )
137+ os .makedirs (name = path , exist_ok = True )
138+ return path
139+
140+
141+ def get_prompt_templates_dir () -> str :
142+ path = os .path .join (get_workspace_dir (), "prompt_templates" )
143+ os .makedirs (name = path , exist_ok = True )
144+ return path
145+
123146
147+ def get_tools_dir () -> str :
148+ path = os .path .join (get_workspace_dir (), "tools" )
149+ os .makedirs (name = path , exist_ok = True )
150+ return path
124151
125- # Prompt Templates Dir:
126- PROMPT_TEMPLATES_DIR = os .path .join (get_workspace_dir (), "prompt_templates" )
127- os .makedirs (name = PROMPT_TEMPLATES_DIR , exist_ok = True )
128152
129- # Tools Dir:
130- TOOLS_DIR = os .path .join (get_workspace_dir (), "tools" )
131- os .makedirs (name = TOOLS_DIR , exist_ok = True )
153+ def get_batched_prompts_dir () -> str :
154+ path = os .path .join (get_workspace_dir (), "batched_prompts" )
155+ os .makedirs (name = path , exist_ok = True )
156+ return path
132157
133- # Batched Prompts Dir:
134- BATCHED_PROMPTS_DIR = os .path .join (get_workspace_dir (), "batched_prompts" )
135- os .makedirs (name = BATCHED_PROMPTS_DIR , exist_ok = True )
136158
137- GALLERIES_CACHE_DIR = os .path .join (get_workspace_dir (), "galleries" )
138- os .makedirs (name = GALLERIES_CACHE_DIR , exist_ok = True )
159+ def get_galleries_cache_dir () -> str :
160+ path = os .path .join (get_workspace_dir (), "galleries" )
161+ os .makedirs (name = path , exist_ok = True )
162+ return path
163+
139164
140165# Evals output file:
141166# TODO: These should probably be in the plugin subclasses
0 commit comments