ananke.services.collection package
Submodules
ananke.services.collection.exporters module
Module containing all collection exporters.
- class ananke.services.collection.exporters.AbstractCollectionExporter(configuration: ExportConfiguration_)[source]
Bases:
ABC
,Generic
[ExportConfiguration_
]Abstract parent class for collection exporters.
- class ananke.services.collection.exporters.GraphNetCollectionExporter(configuration: ExportConfiguration_)[source]
Bases:
AbstractCollectionExporter
[GraphNetExportConfiguration
]Concrete implementation for Graph Net exports.
ananke.services.collection.importers module
Module containing all logic to import collections.
- class ananke.services.collection.importers.AbstractCollectionImporter(collection: Collection)[source]
Bases:
ABC
Abstract parent class for collection importers.
- class ananke.services.collection.importers.LegacyCollectionKeys(value)[source]
Bases:
str
,Enum
Enum containing keys for the collection file.
- RECORDS = 'records'
- HITS = 'hits'
- SOURCES = 'sources'
- DETECTOR = 'detector'
- class ananke.services.collection.importers.LegacyCollection(data_path: str, complevel: int = 3, complib: str = 'lzo', read_only: bool = False)[source]
Bases:
object
Class combining all data frames to a complete record collection.
- get_detector() Optional[Detector] [source]
Gets detector of the collection.
- Returns:
Detector of the collection.
- get_records(record_type: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None) Optional[Records] [source]
Gets records of the collection.
- Parameters:
record_type – record type to include
- Returns:
Records of the collection.
- class ananke.services.collection.importers.LegacyCollectionImporter(collection: Collection)[source]
Bases:
AbstractCollectionImporter
Class to import legacy collection to current one.
ananke.services.collection.storage module
Module containing all the storage interfaces for collections.
- class ananke.services.collection.storage.AbstractCollectionStorage(configuration: CollectionStorageConfiguration_)[source]
Bases:
ABC
,Generic
[CollectionStorageConfiguration_
]Interface for all Collection Storage interfaces.
- abstract open() AbstractCollectionStorage [source]
Opens storage connection.
- abstract get_detector() Optional[Detector] [source]
Gets the detector of the current collection.
- Returns:
Detector of collection or None if empty.
- abstract set_detector(detector: Detector, append: bool = False) None [source]
Sets the detector for current storage.
- Parameters:
detector – Detector to set
append – Append to existing detector
- abstract get_records(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Records] [source]
Gets the records of the current collection.
- Parameters:
types – Type of records to get
record_ids – record_ids to pick
interval – only records in interval
- Returns:
Records of collection or None if empty.
- abstract set_records(records: Records, append: bool = True) None [source]
Sets the records for current storage.
- Parameters:
records – Records to set
append – Append to existing detector
- abstract del_records(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes records of collection storage.
- Parameters:
types – Type of records to get
record_ids – record_ids to pick
interval – only records in interval
- abstract get_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Hits] [source]
Gets the hits of the current collection.
- Parameters:
types – Type of hits to get
record_ids – record_ids to pick
interval – only hits in interval
- Returns:
Hits of collection or None if empty.
- abstract set_hits(hits: Hits, append: bool = True) None [source]
Sets the hits for current storage.
- Parameters:
hits – Hits to set
append – Append to existing detector
- abstract del_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes hits of collection storage.
- Parameters:
types – Type of hits to get
record_ids – record_ids to pick
interval – only hits in interval
- abstract get_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Sources] [source]
Gets the sources of the current collection.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- Returns:
Sources of collection or None if empty.
- abstract set_sources(sources: Sources, append: bool = True) None [source]
Sets the sources for current storage.
- Parameters:
sources – Sources to set
append – Append to existing detector
- abstract del_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes sources of collection storage.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- abstract get_next_record_ids(n: int = 1) List[int] [source]
Gets n next record ids for generation.
- Parameters:
n – Number of record ids to generate
- Returns:
List of integers
- get_record_ids_with_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Series [source]
Gets all record ids with hits.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- Returns:
Pandas Series containing all record ids
- get_record_ids_with_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Series [source]
Gets all record ids with hits.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- Returns:
Pandas Series containing all record ids
- class ananke.services.collection.storage.StorageKeys(value)[source]
Bases:
Enum
Enum containing keys for the collection file.
- RECORDS = 'records'
- HITS = 'hits'
- SOURCES = 'sources'
- DETECTOR = 'detector'
- class ananke.services.collection.storage.MemoryCollectionStorage(configuration: HDF5StorageConfiguration)[source]
Bases:
AbstractCollectionStorage
[MemoryStorageConfiguration
]- open() MemoryCollectionStorage [source]
Opens storage connection.
- get_detector() Optional[Detector] [source]
Gets the detector of the current collection.
- Returns:
Detector of collection or None if empty.
- set_detector(detector: Detector, append: bool = False) None [source]
Sets the detector for current storage.
- Parameters:
detector – Detector to set
append – Append to existing detector
- get_records(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Records] [source]
Gets the records of the current collection.
- Parameters:
types – Type of records to get
record_ids – record_ids to pick
interval – only records in interval
- Returns:
Records of collection or None if empty.
- set_records(records: Records, append: bool = True) None [source]
Sets the records for current storage.
- Parameters:
records – Records to set
append – Append to existing detector
- del_records(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes records of collection storage.
- Parameters:
types – Type of records to get
record_ids – record_ids to pick
interval – only records in interval
- get_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Hits] [source]
Gets the hits of the current collection.
- Parameters:
types – Type of hits to get
record_ids – record_ids to pick
interval – only hits in interval
- Returns:
Hits of collection or None if empty.
- set_hits(hits: Hits, append: bool = True) None [source]
Sets the hits for current storage.
- Parameters:
hits – Hits to set
append – Append to existing detector
- del_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes hits of collection storage.
- Parameters:
types – Type of hits to get
record_ids – record_ids to pick
interval – only hits in interval
- get_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Sources] [source]
Gets the sources of the current collection.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- Returns:
Sources of collection or None if empty.
- set_sources(sources: Sources, append: bool = True) None [source]
Sets the sources for current storage.
- Parameters:
sources – Sources to set
append – Append to existing detector
- del_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes sources of collection storage.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- get_next_record_ids(n: int = 1) List[int] [source]
Gets n next record ids for generation.
- Parameters:
n – Number of record ids to generate
- Returns:
List of integers
- get_record_ids_with_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Series [source]
Gets all record ids with hits.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- Returns:
Pandas Series containing all record ids
- get_record_ids_with_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Series [source]
Gets all record ids with hits.
- Parameters:
types – Type of sources to get
record_ids – record_ids to pick
interval – only sources in interval
- Returns:
Pandas Series containing all record ids
- class ananke.services.collection.storage.HDF5CollectionStorage(configuration: HDF5StorageConfiguration)[source]
Bases:
AbstractCollectionStorage
[HDF5StorageConfiguration
]Implementation for collection storage using HDF5 file format.
- property store: HDFStore
Gets the HDF5 store.
- Returns:
HDF5 store object of storage.
- open() HDF5CollectionStorage [source]
Opens the file io connection.
- Returns:
Itself to work with open storage
- get_detector() Optional[Detector] [source]
Gets the detector from HDF5.
- Returns:
Detector from file
- set_detector(detector: Detector, append: bool = True) None [source]
Sets the detector to HDF5.
- Parameters:
detector – detector to store
append – append to current one
- get_records(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Records] [source]
Gets the records from HDF5.
- Parameters:
types – Types to filter by.
record_ids – Record Ids to filter by.
interval – Interval to filter by.
- Returns:
Records matching criteria.
- set_records(records: Records, append: bool = True) None [source]
Sets the records to HDF5.
- Parameters:
records – records to store
append – append to current one
- del_records(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes the records matching criteria from HDF5.
- Parameters:
types – Types to filter by.
record_ids – Record Ids to filter by.
interval – Interval to filter by.
- get_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Hits] [source]
Gets the hits from HDF5.
- Parameters:
types – Types to filter by.
record_ids – Record Ids to filter by.
interval – Interval to filter by.
- Returns:
Hits matching criteria.
- set_hits(hits: Hits, append: bool = True) None [source]
Sets the hits to HDF5.
- Parameters:
hits – hits to store
append – append to current one
- del_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes the hits matching criteria from HDF5.
- Parameters:
types – Types to filter by.
record_ids – Record Ids to filter by.
interval – Interval to filter by.
- get_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Optional[Sources] [source]
Gets the sources from HDF5.
- Parameters:
types – Types to filter by.
record_ids – Record Ids to filter by.
interval – Interval to filter by.
- Returns:
Sources matching criteria.
- set_sources(sources: Sources, append: bool = True) None [source]
Sets the sources to HDF5.
- Parameters:
sources – sources to store
append – append to current one
- del_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) None [source]
Deletes the sources matching criteria from HDF5.
- Parameters:
types – Types to filter by.
record_ids – Record Ids to filter by.
interval – Interval to filter by.
- get_next_record_ids(n: int = 1) List[int] [source]
Generates an auto increment based of the highest current record id.
- Parameters:
n – Number of record ids to be generated
- Returns:
List of integer ids
- get_record_ids_with_hits(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Series [source]
Gets all unique record ids of records with hits or empty series if empty.
- Parameters:
types – Record types to filter by
record_ids – Record ids to filter by
interval – timeframe to filter by
- Returns:
Unique record ids or empty series of records with hits
- get_record_ids_with_sources(types: Optional[Union[List[Union[EventType, NoiseType, SourceType, RecordType]], EventType, NoiseType, SourceType, RecordType]] = None, record_ids: Optional[Union[int, List[int], Series]] = None, interval: Optional[Interval] = None) Series [source]
Gets all unique record ids of records with sources or empty series if empty.
- Parameters:
types – Record types to filter by
record_ids – Record ids to filter by
interval – timeframe to filter by
- Returns:
Unique record ids or empty series of records with sources
- class ananke.services.collection.storage.StorageFactory[source]
Bases:
object
Class as factory for collection storages.
- configuration_mapping: Dict[Type[StorageConfiguration], Type[AbstractCollectionStorage]] = {<class 'ananke.configurations.collection.HDF5StorageConfiguration'>: <class 'ananke.services.collection.storage.HDF5CollectionStorage'>}
Mapping from configuration to actual storage class
- classmethod create(configuration: StorageConfiguration) AbstractCollectionStorage [source]
Takes a configuration for a storage and returns according storage class.
- Parameters:
configuration – Configuration for current storage
- Returns:
Collection storage to get and retrieve data from
Module contents
Package containing all the services related to collections.