Introduzione
Megara è la libreria in Python per comunicare con le piattaforme cloud di Enersem: EMS e Knolval.
Perché Megara? Si era pensato di chiamare la piattaforma Ercole, ma poi si è scelto diversamente. Nel frattempo, si era pensato ad un nome simpatico per l'SDK in python: la moglie di Ercole. Poi però, la piattaforma è stata chiamata EMS, ed è pure venuto fuori da accurate ricerche bibliografiche che Megara è stata vittima di femminicidio. Ma ormai il nome era stato dato. Qui qualche storia: wikipedia, con l'immagine: logo
Segue la documentazione delle funzionalità
- Funzione
change_server - Classe
Company - Classe
Group - Classe
ObjectMetadata - Classe
Arke - Classe
Parameter - Classe
ArkeUnit - Classe
Algorithm - Classe
Elaboration - Classe
Optimization - Funzione
simulate_cron - Classe
Smarthia - Classe
DatabaseUtils - Classe
Chrono - Classe
Backoffice
Metodo change_server
Change server.
Parametri
- server (str or int or None) Can be the address of the server without the https part, the int referencing the server in the list, or None, in which case it will ask for it.
- verbose (bool) If false, suppress output
Metodo simulate_cron
Run multiple elaborations and optimizations, simulating the cron scheduler. Retrieve the frequencies associated to the elaborations and optimizations requested, and create a list of timestamp between start and end that match the moments in which these elaborations and optimization would have been executed.
Parametri
- start (str)
- end (str)
- arke_id (str)
- arke_unit_id (str) If None, the elaboration run on all units of the arke or group.
- group (str) Alternative to the previous two.
- elaborations (list) A list of elaborations arke_key. If None, optimizations can't be None.
- optimizations (list)
- cooldown_time (int) Number of seconds to wait between a retry after a Gateway Timeout (504)
- policy (str) Policy to adopt in case of error: "retry", "continue"
- only_result (bool) Run algorithms without writing the result in the DB.
Restituisce
- list A list of the HTTP codes resulting from each elaboration or optimization run. Beware the teapot!
Esempi di utilizzo
>>> meg.simulate_cron('trigen', 1, ['chp_elab_raw', 'chp_elab_weekly'], [],
... start='2021-01-01', end='2021-02-16')
Classe SamplingType
Membri:
- INCREMENTAL (incremental)
- INSTANTANEOUS (instantaneous)
- TIMESPAN_AVERAGE (timespan average value)
- TIMESPAN_SUMMED (timespan summed value)
- EVENT (event)
Classe AggregationFunction
Membri:
- MEAN (mean)
- SUM (sum)
- NANSUM (nansum)
- MIN (min)
- MAX (max)
- FIRST (first)
- MODE (mode)
- NEWEST (newest)
- OLDEST (oldest)
Classe Granularity
Costruttore
Create a Granularity.
Parametri
- string (str) It can be composed by an integer followed by one or more letter identifiying the frequency. Available options are:
- B: business day (weekday)
- C: custom business day
- W: one week, optionally anchored on a day of the week
- WOM: the x-th day of the y-th week of each month
- LWOM: the x-th day of the last week of each month
- M: calendar month end
- MS: calendar month begin
- BM: business month end
- BMS: business month begin
- CBM: custom business month end
- CBMS: custom business month begin
- SM: 15th (or other day_of_month) and calendar month end
- SMS: 15th (or other day_of_month) and calendar month begin
- Q: calendar quarter end
- QS: calendar quarter begin
- BQ: business quarter end
- BQS: business quarter begin
- REQ: retail (aka 52 - 53 week) quarter
- A: calendar year end
- AS: calendar year begin
- BA: business year end
- BAS: business year begin
- RE: retail (aka 52 - 53 week) year
- BH: business hour
- CBH: custom business hour
- D: one absolute day
- H: one hour
- min: one minute
- T: one minute
- S: one second
- L: one millisecond
- ms: one millisecond
- U: one microsecond
- us: one microsecond
- N: one nanosecond