Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔁: Updated plugins loading workflow to be able to store them o… #325

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Empty file.
Empty file.
File renamed without changes.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
File renamed without changes.
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion taskweaver/code_interpreter/code_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _save_file(
def load_plugin(self):
for p in self.plugin_registry.get_list():
try:
src_file = f"{self.config.app_base_path}/plugins/{p.impl}.py"
src_file = f"{self.config.app_base_path}/plugins/{p.impl}/{p.impl}.py"
with open(src_file, "r") as f:
plugin_code = f.read()
self.exec_client.load_plugin(
Expand Down
2 changes: 1 addition & 1 deletion taskweaver/memory/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def provide_plugin_registry(
) -> PluginRegistry:
import os

file_glob = os.path.join(config.base_path, "*.yaml")
file_glob = os.path.join(config.base_path, '**',"*.yaml")
return PluginRegistry(
file_glob=file_glob,
ttl=timedelta(minutes=10),
Expand Down
12 changes: 12 additions & 0 deletions taskweaver/misc/component_registry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from abc import ABC, abstractmethod
from datetime import datetime, timedelta
from typing import Dict, Generic, List, Optional, Tuple, TypeVar, Union
Expand Down Expand Up @@ -33,6 +34,15 @@ def is_available(self, freshness: Optional[timedelta] = None) -> bool:
return False
return True

def _should_skip_plugin_file(self, path):
splitted_path = path.split(os.sep)
is_plugin = os.path.join('plugins','project') in path
is_plugin_yaml = splitted_path[-2] == splitted_path[-1].split('.')[0]
if is_plugin:
if not is_plugin_yaml:
return True
return False

def get_registry(
self,
force_reload: bool = False,
Expand All @@ -45,6 +55,8 @@ def get_registry(

registry: Dict[str, component_type] = {}
for path in glob_files(self._file_glob):
if self._should_skip_plugin_file(path):
continue
try:
name, component = self._load_component(path)
except ComponentDisabledException:
Expand Down
Loading