Skip to content

Commit

Permalink
feat: added to experiments library
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Dec 1, 2023
1 parent 9d6efe6 commit ae4aadd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions process_bigraph/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,15 @@ def get_data(self, query: Optional[List[Tuple[str]]] = None) -> Dict:
return get_history_data_db(self.history, self.experiment_id, query)

def query(self, query: Optional[List[Tuple[str]]] = None) -> Dict:
"""API contract-wrapper for `self.get_data`. Get data based on the passed query.
Args:
query: a list of tuples pointing to fields within the experiment data.
In the format: [('path', 'to', 'field1'), ('path', 'to', 'field2')]
Returns:
`Dict`
"""
return self.get_data(query)

def update(self, state):
Expand Down
18 changes: 18 additions & 0 deletions process_bigraph/experiments/smoldyn_database.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""A test of the `..emitter.DatabaseEmitter` class with Smoldyn to emit and query the formatted results of
a Smoldyn simulation. The db workflow could be described as:
0. A local MongoDB server is spun up. # TODO: Automatically check for this and kill/start as needed.
1. A Smoldyn simulation object is created by reading in a Smoldyn model.txt file.
2. Smoldyn "datasets" (output commands) are added using the Python API despite what `cmd` lines are
declared in the Smoldyn model file. (`addOutputData` && `addCommand`)
3. The Smoldyn simulation runs for the specified time params dependent on which simulation method is used.
4. The raw data is retrieved and formatted (`getOutputData` for time and listmols)
5. An instance of DatabaseEmitter is created.
6. The simulation data from #4's output is used as input for the database emitter and emitted to memory.
7. This process is repeated `N` times.
8. The user queries the vast database based on simulation run id.
Currently, this emitter works with MongoDB. TODO: include dbTypes
"""


0 comments on commit ae4aadd

Please sign in to comment.