44import time
55from enum import Enum
66from pathlib import Path
7+ from typing import Optional
78
89import click
910from kubernetes .stream import stream
@@ -81,8 +82,9 @@ def _entrypoint(ctx, plugin_content: dict, warnet_content: dict):
8182 """Called by entrypoint"""
8283 # write your plugin startup commands here
8384 activity = plugin_content .get (PluginContent .ACTIVITY .value )
84- activity = json .loads (activity )
85- print (activity )
85+ if activity :
86+ activity = json .loads (activity )
87+ print (activity )
8688 _launch_activity (activity , ctx .obj .get (PLUGIN_DIR_TAG ))
8789
8890
@@ -132,8 +134,8 @@ def launch_activity(ctx, activity: str):
132134 print (_launch_activity (parsed_activity , plugin_dir ))
133135
134136
135- def _launch_activity (activity : list [dict ], plugin_dir : str ) -> str :
136- """Launch a SimLN chart which includes the `activity`"""
137+ def _launch_activity (activity : Optional [ list [dict ] ], plugin_dir : str ) -> str :
138+ """Launch a SimLN chart which optionally includes the `activity`"""
137139 timestamp = int (time .time ())
138140 name = f"simln-{ timestamp } "
139141
@@ -156,7 +158,7 @@ def _launch_activity(activity: list[dict], plugin_dir: str) -> str:
156158 raise PluginError (f"Could not write sim.json to the init container: { name } " )
157159
158160
159- def _generate_activity_json (activity : list [dict ]) -> str :
161+ def _generate_activity_json (activity : Optional [ list [dict ] ]) -> str :
160162 nodes = []
161163
162164 for i in get_mission (LIGHTNING_MISSION ):
@@ -169,7 +171,10 @@ def _generate_activity_json(activity: list[dict]) -> str:
169171 }
170172 nodes .append (node )
171173
172- data = {"nodes" : nodes , PluginContent .ACTIVITY .value : activity }
174+ if activity :
175+ data = {"nodes" : nodes , PluginContent .ACTIVITY .value : activity }
176+ else :
177+ data = {"nodes" : nodes }
173178
174179 return json .dumps (data , indent = 2 )
175180
0 commit comments