Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexPatrie committed Dec 1, 2023
1 parent 7edec48 commit 8a35e6a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions process_bigraph/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import orjson
import collections
import itertools
import sqlite3
from functools import partial
from warnings import warn
from typing import Any, Dict, List, Optional, Tuple, Callable, Union
Expand All @@ -16,6 +17,7 @@
from pymongo import ASCENDING
from pymongo.errors import DocumentTooLarge
from pymongo.mongo_client import MongoClient
from pymongo.collection import Collection
from bson import MinKey, MaxKey

from bigraph_schema import get_path, set_path
Expand Down Expand Up @@ -92,7 +94,7 @@ def query(self, query=None):
return result


class _DatabaseEmitter(Emitter):
'''class _DatabaseEmitter(Emitter):
"""ABC for emitting data to some sort of Database."""
default_host: str
Expand Down Expand Up @@ -133,13 +135,18 @@ class SqliteDatabaseEmitter(_DatabaseEmitter):
"""TODO: Implement this class for simple simulations/no Mongo access as this is built in to Python."""
config_schema = {
'ports': 'tree[any]'
'ports': {
'db_name': 'string'
}
}
def __init__(self, config):
super().__init__(config)
self.conn = sqlite3.connect(self.config['ports'].get('db_name'))
self.cursor = self.conn.cursor()

def emit(self, table_id: str):
pass '''


class DatabaseEmitter(Emitter):
Expand Down Expand Up @@ -259,7 +266,7 @@ def emit(self, data: Dict[str, Any]) -> None:
emit_data['experiment_id'] = self.experiment_id
self.write_emit(table, emit_data)

def write_emit(self, table: Any, emit_data: Dict[str, Any]) -> None:
def write_emit(self, table: Collection, emit_data: Dict[str, Any]) -> None:
"""Check that data size is less than emit limit.
Break up large emits into smaller pieces and emit them individually
Expand Down Expand Up @@ -509,7 +516,7 @@ def breakdown_data(


def get_history_data_db(
history_collection: Any,
history_collection: Collection,
experiment_id: Any,
query: Optional[List] = None,
func_dict: Optional[Dict] = None,
Expand Down

0 comments on commit 8a35e6a

Please sign in to comment.