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:

AbstractStorageDriver(config)

The abstract storage driver is the base class for all storage driver classes.

DirectusAPI(host, token, collection)

The DirectusAPI class provides the needed tools to interact with the Directus API.

DirectusStorageDriver(config)

This storage driver handles storing snapshots to in Directus using the Directus API.

JSONStorageDriver(config)

This storage driver handles appending snapshots to JSON files.

SQLiteStorageDriver(config)

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
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.

clearCache()

Clear the Directus cache.

collectionExists()

Test whether a collection exists.

createCollection()

Create the collection.

createField(name, dataType)

Create a field in the collection.

get(endpoint[, log])

Get data from a given endpoint.

getFields()

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

clearCache()[source]

Clear the Directus cache.

Returns

The response data

Return type

dict

collectionExists()[source]

Test whether a collection exists.

Returns

True if the collection exists

Return type

bool

createCollection()[source]

Create the collection.

Returns

The response data

Return type

dict

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

getFields()[source]

Get the fields list of a collection.

Returns

The list of fields

Return type

list

post(endpoint, data)[source]

Post data to a given enpoint.

Parameters
  • endpoint (string) – The endpoint

  • data (dict) – The data dict

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
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
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