Skip to content

Commit daea5e0

Browse files
committed
remove "warnet consumes plugin"
1 parent a9cb566 commit daea5e0

File tree

8 files changed

+20
-319
lines changed

8 files changed

+20
-319
lines changed

resources/plugins/simln/plugin.yaml

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/plugins/simln/simln.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
import logging
55
import time
66
from pathlib import Path
7-
from typing import Optional
87

98
import click
109
from kubernetes.stream import stream
1110

1211
# When we want to select pods based on their role in Warnet, we use "mission" tags. The "mission"
1312
# tag for "lightning" nodes is stored in LIGHTNING_MISSION.
14-
from warnet.constants import LIGHTNING_MISSION, USER_DIR_TAG
13+
from warnet.constants import LIGHTNING_MISSION, PLUGIN_DIR_TAG
1514
from warnet.k8s import (
1615
download,
1716
get_default_namespace,
@@ -20,7 +19,6 @@
2019
wait_for_init,
2120
write_file_to_container,
2221
)
23-
from warnet.plugins import get_plugins_directory_or
2422
from warnet.process import run_command
2523

2624
# To make a "mission" tag for your plugin, declare it using the variable name MISSION. This will
@@ -55,15 +53,9 @@ class SimLNError(Exception):
5553
@click.pass_context
5654
def simln(ctx):
5755
"""Commands for the SimLN plugin"""
58-
try:
59-
# check if we have set a user directory
60-
ctx.obj.get(USER_DIR_TAG)
61-
except Exception:
62-
# if not, set the great-grandparent of this file as the user dir
63-
ctx.ensure_object(dict)
64-
user_dir = Path(__file__).resolve().parent.parent.parent
65-
ctx.obj[USER_DIR_TAG] = Path(user_dir)
66-
pass
56+
ctx.ensure_object(dict)
57+
plugin_dir = Path(__file__).resolve().parent
58+
ctx.obj[PLUGIN_DIR_TAG] = Path(plugin_dir)
6759

6860

6961
# Make sure to register your plugin by adding the group function like so:
@@ -74,8 +66,8 @@ def warnet_register_plugin(register_command):
7466
# The group function name is then used in decorators to create commands. These commands are
7567
# available to users when they access your plugin from the command line in Warnet.
7668
@simln.command()
77-
def list_simln_podnames():
78-
"""Get a list of simln pod names"""
69+
def list_pod_names():
70+
"""Get a list of SimLN pod names"""
7971
print([pod.metadata.name for pod in get_mission(MISSION)])
8072

8173

@@ -111,14 +103,12 @@ def get_example_activity():
111103
print(json.dumps(_get_example_activity()))
112104

113105

114-
def _launch_activity(activity: list[dict], user_dir: Optional[str] = None) -> str:
106+
def _launch_activity(activity: list[dict], plugin_dir: str) -> str:
115107
"""Launch a SimLN chart which includes the `activity`"""
116-
plugin_dir = get_plugins_directory_or(user_dir)
117-
118108
timestamp = int(time.time())
119109
name = f"simln-{timestamp}"
120110

121-
command = f"helm upgrade --install {timestamp} {plugin_dir}/simln/charts/simln"
111+
command = f"helm upgrade --install {timestamp} {plugin_dir}/charts/simln"
122112
run_command(command)
123113

124114
activity_json = _generate_activity_json(activity)
@@ -147,8 +137,8 @@ def launch_activity(ctx, activity: str):
147137
except json.JSONDecodeError:
148138
log.error("Invalid JSON input for activity.")
149139
raise click.BadArgumentUsage("Activity must be a valid JSON string.") from None
150-
user_dir = ctx.obj.get(USER_DIR_TAG)
151-
print(_launch_activity(parsed_activity, user_dir))
140+
plugin_dir = ctx.obj.get(PLUGIN_DIR_TAG)
141+
print(_launch_activity(parsed_activity, plugin_dir))
152142

153143

154144
def _generate_activity_json(activity: list[dict]) -> str:

src/warnet/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
DEFAULTS_NAMESPACE_FILE = "namespace-defaults.yaml"
4343

4444
# Plugin architecture
45-
USER_DIR_TAG = "user_dir"
45+
PLUGIN_DIR_TAG = "plugin_dir"
4646
PLUGINS_TAG = "plugins"
4747
ENABLED_TAG = "enabled"
4848
PLUGIN_YAML = "plugin.yaml"

src/warnet/control.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import io
2-
import itertools
32
import json
43
import os
54
import subprocess
@@ -42,7 +41,6 @@
4241
wait_for_pod,
4342
write_file_to_container,
4443
)
45-
from .plugins import get_plugin_missions, get_plugin_primary_containers
4644
from .process import run_command, stream_command
4745

4846
console = Console()
@@ -386,11 +384,8 @@ def format_pods(pods: list[V1Pod]) -> list[str]:
386384
pod_list = []
387385
formatted_commanders = format_pods(get_mission(COMMANDER_MISSION))
388386
formatted_tanks = format_pods(get_mission(TANK_MISSION))
389-
plugin_pods = [get_mission(mission) for mission in get_plugin_missions()]
390-
formatted_plugins = format_pods(list(itertools.chain.from_iterable(plugin_pods)))
391387
pod_list.extend(formatted_commanders)
392388
pod_list.extend(formatted_tanks)
393-
pod_list.extend(formatted_plugins)
394389

395390
except Exception as e:
396391
print(f"Could not fetch any pods in namespace ({namespace}): {e}")
@@ -416,7 +411,6 @@ def format_pods(pods: list[V1Pod]) -> list[str]:
416411
try:
417412
pod = get_pod(pod_name, namespace=namespace)
418413
eligible_container_names = [BITCOINCORE_CONTAINER, COMMANDER_CONTAINER]
419-
eligible_container_names.extend(get_plugin_primary_containers())
420414
available_container_names = [container.name for container in pod.spec.containers]
421415
container_name = next(
422416
(

src/warnet/main.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
from pathlib import Path
2-
31
import click
42

5-
from warnet.constants import USER_DIR_TAG
6-
73
from .admin import admin
84
from .bitcoin import bitcoin
95
from .control import down, logs, run, snapshot, stop
@@ -12,25 +8,13 @@
128
from .graph import create, graph, import_network
139
from .image import image
1410
from .ln import ln
15-
from .plugins import load_plugins, load_user_modules, plugins
1611
from .project import init, new, setup
1712
from .status import status
1813
from .users import auth
1914

2015

2116
@click.group()
22-
@click.option(
23-
"--user-dir",
24-
type=click.Path(exists=True, file_okay=False),
25-
help="Path to the user's Warnet project directory.",
26-
)
27-
@click.pass_context
28-
def cli(ctx, user_dir: str):
29-
ctx.ensure_object(dict) # initialize ctx object
30-
if user_dir:
31-
ctx.obj[USER_DIR_TAG] = Path(user_dir)
32-
if load_user_modules(ctx.obj.get(USER_DIR_TAG)):
33-
load_plugins()
17+
def cli():
3418
pass
3519

3620

@@ -53,7 +37,6 @@ def cli(ctx, user_dir: str):
5337
cli.add_command(status)
5438
cli.add_command(stop)
5539
cli.add_command(create)
56-
cli.add_command(plugins)
5740

5841

5942
if __name__ == "__main__":

src/warnet/plugins.py

Lines changed: 0 additions & 224 deletions
This file was deleted.

0 commit comments

Comments
 (0)