revitron.analyze.storage¶
This submodule is a collection of storage drivers that can be used to store extracted model information in different types of formats such as SQLite, JSON or API based databases.
Classes:
|
The abstract storage driver is the base class for all storage driver classes. |
|
The DirectusAPI class provides the needed tools to interact with the Directus API. |
|
This storage driver handles storing snapshots to in Directus using the Directus API. |
|
This storage driver handles appending snapshots to JSON files. |
|
This storage driver handles the connection to the SQLite database as well as the actual creation of the snapshots. |
- class AbstractStorageDriver(config)[source]¶
Bases:
object
The abstract storage driver is the base class for all storage driver classes.
Methods:
__init__
(config)Init a new storage driver instance with a givenm configuration.
add
(dataProviderResults, modelSize)Add a new snapshot.
- __init__(config)[source]¶
Init a new storage driver instance with a givenm configuration.
- Parameters
config (dict) – The driver configuration
- abstract add(dataProviderResults, modelSize)[source]¶
Add a new snapshot.
- Parameters
dataProviderResults (list) – The list of
revitron.analyze.DataProviderResult
objectsmodelSize (float) – The local file’s size in bytes
- class DirectusAPI(host, token, collection)[source]¶
Bases:
object
The DirectusAPI class provides the needed tools to interact with the Directus API.
Methods:
__init__
(host, token, collection)Init a new API wrapper instance.
Clear the Directus cache.
Test whether a collection exists.
Create the collection.
createField
(name, dataType)Create a field in the collection.
get
(endpoint[, log])Get data from a given endpoint.
Get the fields list of a collection.
post
(endpoint, data)Post data to a given enpoint.
- __init__(host, token, collection)[source]¶
Init a new API wrapper instance.
- Parameters
host (string) – The API URL
token (string) – The API token that is used for authentication
collection (string) – The collection name
- collectionExists()[source]¶
Test whether a collection exists.
- Returns
True if the collection exists
- Return type
bool
- createField(name, dataType)[source]¶
Create a field in the collection.
- Parameters
name (string) – The field name
dataType (string) – The data type for the field
- Returns
The response data
- Return type
dict
- get(endpoint, log=True)[source]¶
Get data from a given endpoint.
- Parameters
endpoint (string) – The Directus API endpoint
log (bool, optional) – Enable logging. Defaults to True.
- Returns
The reponse dictionary
- Return type
dict
- class DirectusStorageDriver(config)[source]¶
Bases:
AbstractStorageDriver
This storage driver handles storing snapshots to in Directus using the Directus API.
Methods:
__init__
(config)Init a new Directus storage driver instance with a givenm configuration.
add
(dataProviderResults, modelSize)Send a POST request to the Directus API in order store a snapshot
- __init__(config)[source]¶
Init a new Directus storage driver instance with a givenm configuration.
- Parameters
config (dict) – The driver configuration
- add(dataProviderResults, modelSize)[source]¶
Send a POST request to the Directus API in order store a snapshot
- Parameters
dataProviderResults (list) – The list of
revitron.analyze.DataProviderResult
objectsmodelSize (float) – The model size in bytes
- class JSONStorageDriver(config)[source]¶
Bases:
AbstractStorageDriver
This storage driver handles appending snapshots to JSON files.
Methods:
__init__
(config)Init a new storage driver instance with a givenm configuration.
add
(dataProviderResults, modelSize)Add a new item to JSON file.
- __init__(config)¶
Init a new storage driver instance with a givenm configuration.
- Parameters
config (dict) – The driver configuration
- add(dataProviderResults, modelSize)[source]¶
Add a new item to JSON file.
- Parameters
dataProviderResults (list) – The list of
revitron.analyze.DataProviderResult
objectsmodelSize (float) – The local file’s size in bytes
- class SQLiteStorageDriver(config)[source]¶
Bases:
AbstractStorageDriver
This storage driver handles the connection to the SQLite database as well as the actual creation of the snapshots.
Methods:
__init__
(config)Init a new storage driver instance with a givenm configuration.
add
(dataProviderResults, modelSize)Add a new row to the snapshots table.
- __init__(config)¶
Init a new storage driver instance with a givenm configuration.
- Parameters
config (dict) – The driver configuration
- add(dataProviderResults, modelSize)[source]¶
Add a new row to the snapshots table.
- Parameters
dataProviderResults (list) – The list of
revitron.analyze.DataProviderResult
objectsmodelSize (float) – The local file’s size in bytes