-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_examples.py
More file actions
47 lines (39 loc) · 1.45 KB
/
setup_examples.py
File metadata and controls
47 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
from ml_deploy.stored_model_utils import StoredModelUtils, S3_StoredModelUtils
from sqlalchemy import create_engine
import os
# SQL Alchemy Engines
#--------------------
# 1 - SQLite in-memory engine
sa_engine = create_engine('sqlite:///:memory:', echo=True)
# 2 - Local SQLite database engine
db_path = 'c:\\users\\scrooge.mcduck\\desktop\\ml_deploy.db'
conn_string = 'sqlite:///' + db_path
sa_engine = create_engine(conn_string)
# 3 - Postgres engine
# Redshift is only partially supported by sqlalchemy at this time.
username = 'mcduck'
password = os.getenv('mcduck-pw')
host = 'host.ucoachapp.com'
port = 5432
database = 'dbname'
template = 'postgresql+psycopg2://{username}:{password}@{host}:{port}/{database}'
conn_string = template.format(username=username,
password=password,
host=host,
port=port,
database=database)
sa_engine = create_engine(conn_string)
# initializing the ml_deploy data model
from ml_deploy.models import create_data_model
create_data_model(sa_engine)
# StoredModelUtil objects
#------------------------
# Local StoredModelUtil object
smu_dir = 'c:\\users\\scrooge.mcduck\\desktop\\stored_mdoels'
smu = StoredModelUtils(smu_dir)
# S3_StoredModelUtil object
s3_access = os.getenv('s3-access')
s3_secret = os.getenv('s3-secret')
bucket = 'ml-deploy'
s3_smu = S3_StoredModelUtils(s3_access, s3_secret, bucket)