import datetime as dt
import json
import pandas as pd
import numpy as np
import logging
from sqlalchemy import Column, Integer, String, Float, DateTime, Boolean, func
from iotfunctions.base import BaseTransformer
from iotfunctions.metadata import EntityType
from iotfunctions.db import Database
from iotfunctions import ui
from iotfunctions.enginelog import EngineLogging

EngineLogging.configure_console_logging(logging.DEBUG)
'''
This is a script used to genenerate the SQL used to import
built in functions into AS
'''

with open('credentials_as_dev.json', encoding='utf-8') as F:
    credentials = json.loads(F.read())
db_schema = None
db = Database(credentials=credentials)

from iotfunctions import bif

db.register_module(module=bif, raise_error=True, force_preinstall=True)
Custom functions must be registered in the AS function catalog before
you can use them. To register a function:
    
'''

db.register_functions([MultiplyTwoItems])
'''
After registration has completed successfully the function is available for
use in the AS UI.

The register_functions() method allows you to register more than one function
at a time. You can also register a whole module file with all of its functions.


'''

from iotfunctions import bif

db.register_module(bif)
'''

Note: The 'bif' module is preinstalled, so these functions will not actually
be registered by register_module.

This script covers the complete process for authoring and registering custom 
functions. The subject of the sample function used in this script was really
basic. To get an idea some of the more interesting things you can do in
custom functions, we encourage you to browse through the sample module.

'''
Exemple #3
0
# if there is a 2nd argument do not register but exit
if (len(sys.argv) > 1):
    sys.exit()

EngineLogging.configure_console_logging(logging.DEBUG)

#with open('credentials_as_dev.json', encoding='utf-8') as F:
#    credentials = json.loads(F.read())

#fn = AggregateItemStats(
#        input_item_1='x1',
#        input_item_2='x2',
#        output_item='y')

#df = fn.execute_local_test(generate_days=1,to_csv=True)
#print(df)

#cols = [
#    Column('string_1', String(255))
#        ]

#df = fn.execute_local_test(generate_days = 1,to_csv=True,
#                           columns = cols)

#db.register_functions([functions.AggregateItemStats])

db.register_module(functions)

db.register_functions([anomaly.SpectralAnomalyScore])
Exemple #4
0
import json
from iotfunctions.db import Database

with open('credentials_as.json', encoding='utf-8') as F:
    credentials = json.loads(F.read())
db_schema = None
db = Database(credentials=credentials)

# from rawkintrevo_tutorial2.divbyfactor import RawkintrevosDivByFactor
from rawkintrevo_tutorial2.LegitRequest import ExternalModel

db.unregister_functions(["ExternalModel"])
db.register_functions([ExternalModel])

import rawkintrevo_tutorial2
db.register_module(rawkintrevo_tutorial2)

import rawkintrevo_tutorial2.LegitRequest
db.register_module(rawkintrevo_tutorial2.LegitRequest)