Skip to content

Commit

Permalink
Merge branch 'dev' into admin_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
LuckierDodge authored Sep 11, 2024
2 parents ba38a8b + fcf6187 commit be01d29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/wei/experiment_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,15 @@ def save_datapoint_value(self, datapoint_id: str, output_filepath: str) -> None:
f.write(response.content)
response.raise_for_status()

def get_experiment_datapoints(self) -> Dict[str, DataPoint]:
"""
returns a dictionary of the datapoints for this experiment.
"""
url = f"{self.url}/{self.experiment_id}/data"
response = requests.get(url)
if response.ok:
return response.json()

def log_experiment_end(self) -> Event:
"""Logs the end of the experiment in the experiment log
Expand Down
11 changes: 11 additions & 0 deletions src/wei/routers/experiment_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from wei.core.experiment import get_experiment, register_new_experiment
from wei.core.state_manager import state_manager
from wei.core.storage import get_experiment_log_file
from wei.types.datapoint_types import DataPoint
from wei.types.event_types import Event
from wei.types.experiment_types import Campaign, Experiment, ExperimentDesign

Expand All @@ -38,6 +39,16 @@ async def check_in(experiment_id: str) -> None:

return

@router.get("/{experiment_id}/data")
async def data_return(experiment_id: str) -> Dict[str, DataPoint]:
"""Returns all of the data points related to an experiment"""
datapoints = {}
for datapoint_id, datapoint in state_manager.get_all_datapoints().items():
if datapoint.experiment_id == experiment_id:
datapoints[datapoint_id] = datapoint
return datapoints



@router.get("/{experiment_id}/log")
async def log_return(experiment_id: str) -> str:
Expand Down

0 comments on commit be01d29

Please sign in to comment.