Skip to content

Commit

Permalink
chore: Update plugin file paths to include repetitions in save path
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanxiao committed May 18, 2024
1 parent 8ccaed3 commit 664e7bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 2 additions & 0 deletions midori/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def run(self) -> None:
subject_path=self.__subject_path,
treatment=treatment,
previous_output=output,
repetitions=i,
)
output = plugin.execute()

Expand All @@ -107,6 +108,7 @@ def run(self) -> None:
subject_path=self.__subject_path,
treatment=treatment,
previous_output=output,
repetitions=i,
)
output = plugin.execute()

Expand Down
6 changes: 4 additions & 2 deletions midori/plugins/example_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def action(self) -> None:
energy_collector: PodHelper = PodHelper(
self._ssh, "prometheus-server", "default"
)
energy_node_save_path = f"~/research/results/{self.treatment}/energy.json"
energy_node_save_path = f"~/research/results/{self.treatment + '-' + str(self.repetitions)}/energy.json"
energy_collector.execute_query_in_pod(
node_saving_path=energy_node_save_path,
query_cmd=energy_collector.construct_query_cmd(),
Expand All @@ -20,6 +20,8 @@ def action(self) -> None:

class LoadTestingDataCollection(PluginHelper):
def action(self) -> None:
treatment_node_save_path = f"~/research/results/{self.treatment}"
treatment_node_save_path = (
f"~/research/results/{self.treatment + '-' + str(self.repetitions)}"
)
pft: PodHelper = PodHelper(self._ssh, "loadgenerator", "default")
pft.transfer_file_from_pod("/loadgen", treatment_node_save_path)
6 changes: 5 additions & 1 deletion midori/plugins/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ def __init__(
subject_path: str,
treatment: str,
previous_output: Optional[str] = None,
repetitions: int = 0,
):
self._ssh = ssh
self.subject_path = subject_path
self.previous_output = previous_output
self.treatment = treatment
self.repetitions = repetitions

@final
def execute(self) -> Optional[str]:
Expand Down Expand Up @@ -117,7 +119,9 @@ def construct_query_cmd(
) -> str:
"""Constructs the query command to be executed inside the pod."""
if end_time is None:
end_time = int(time.time())
end_time = int(
time.time()
) # the total trial timespan is 100s, to get the last 60 seconds
if start_time is None:
start_time = end_time - 60
return f"kubectl exec {self.pod} -- wget -qO- 'http://localhost:9090/api/v1/query_range?query=scaph_host_power_microwatts%20%2F%201000000&start={start_time}&end={end_time}&step=1'"
Expand Down

0 comments on commit 664e7bd

Please sign in to comment.