MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / import_plugins_from_env

Function import_plugins_from_env

api/importer/plugins.py:7–28  ·  view source on GitHub ↗

Import plugins from environment variable Will not import if plugin already exists

(environment_variable_name="IQENGINE_PLUGINS")

Source from the content-addressed store, hash-verified

5
6
7async def import_plugins_from_env(environment_variable_name="IQENGINE_PLUGINS"):
8 """
9 Import plugins from environment variable
10 Will not import if plugin already exists
11 """
12 try:
13 plugins_json = os.getenv(environment_variable_name, None)
14 if not plugins_json:
15 return None
16 plugins = json.loads(plugins_json)
17
18 client = plugin_repo.collection()
19 for plugin in plugins:
20 if await client.find_one({"name": plugin["name"]}, {"_id": 1}):
21 continue
22 await client.insert_one(plugin)
23 except Exception as e:
24 # throw a custom plugin failed to load exception
25 raise Exception(
26 f"Failed to load plugins from environment variable {environment_variable_name}",
27 e,
28 )

Callers 1

import_all_from_envFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected