Skip to content

Commit

Permalink
Warm start a stratey based on config provided seed conditions (#487)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #487

There is a desire to warm start a strategy with data filtered on master table values recorded from previous experiments.

Data can be filtered on any data other than master.unique_id. This means that the below are all valid filter criteria:
- experiment_name
- experiment_description
- experiment_id
- participant_id
- anything stored in extra_metadata

Criteria will follow AND logic between fields, but inclusive OR logic within the same field.

Data will be further filtered out if it does not meet these criteria:
- Each parameter matches on name and type
- Each outcome matches on name and type
- Stimuli per trial are the same

allow-large-files

Reviewed By: crasanders

Differential Revision: D66731597
  • Loading branch information
unrealdev12 authored and facebook-github-bot committed Jan 3, 2025
1 parent 58c1c50 commit 4aebe72
Show file tree
Hide file tree
Showing 10 changed files with 1,040 additions and 21 deletions.
24 changes: 18 additions & 6 deletions aepsych/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,14 @@ def to_dict(self, deduplicate: bool = True) -> Dict[str, Any]:
_dict[section][setting] = self[section][setting]
return _dict

# Turn the metadata section into JSON.
def jsonifyMetadata(self, only_extra: bool = False) -> str:
"""Return a json string of the metadata section.
def get_metadata(self, only_extra: bool = False) -> Dict[Any, Any]:
"""Return a dictionary of the metadata section.
Args:
only_extra (bool): Only jsonify the extra meta data.
only_extra (bool, optional): Only gather the extra metadata. Defaults to False.
Returns:
str: A json string representing the metadata dictionary or an empty string
if there is no metadata to return.
Dict[Any, Any]: a collection of the metadata stored in this conig.
"""
configdict = self.to_dict()
metadata = configdict["metadata"].copy()
Expand All @@ -173,6 +171,20 @@ def jsonifyMetadata(self, only_extra: bool = False) -> str:
for name in default_metadata:
metadata.pop(name, None)

return metadata

# Turn the metadata section into JSON.
def jsonifyMetadata(self, only_extra: bool = False) -> str:
"""Return a json string of the metadata section.
Args:
only_extra (bool): Only jsonify the extra meta data.
Returns:
str: A json string representing the metadata dictionary or an empty string
if there is no metadata to return.
"""
metadata = self.get_metadata(only_extra)
if len(metadata.keys()) == 0:
return ""
else:
Expand Down
Loading

0 comments on commit 4aebe72

Please sign in to comment.