-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconfigure_notebook.py
More file actions
50 lines (34 loc) · 1.21 KB
/
configure_notebook.py
File metadata and controls
50 lines (34 loc) · 1.21 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
48
49
50
# Databricks notebook source
# MAGIC %pip install -r requirements.txt
# COMMAND ----------
import warnings
warnings.filterwarnings("ignore")
# COMMAND ----------
import yaml
with open('config/application.yaml', 'r') as f:
config = yaml.safe_load(f)
# COMMAND ----------
dbutils.fs.mkdirs(config['database']['path'])
_ = sql("CREATE DATABASE IF NOT EXISTS {} LOCATION '{}'".format(
config['database']['name'],
config['database']['path']
))
# COMMAND ----------
# use our newly created database by default
# each table will be created as a MANAGED table under this directory
_ = sql("USE {}".format(config['database']['name']))
# COMMAND ----------
import pandas as pd
portfolio_df = pd.read_json('config/portfolio.json', orient='records')
# COMMAND ----------
import json
with open('config/indicators.json', 'r') as f:
market_indicators = json.load(f)
# COMMAND ----------
import mlflow
username = dbutils.notebook.entry_point.getDbutils().notebook().getContext().userName().get()
mlflow.set_experiment('/Users/{}/value_at_risk'.format(username))
# COMMAND ----------
def teardown():
_ = sql("DROP DATABASE IF EXISTS {} CASCADE".format(config['database']['name']))
dbutils.fs.rm(config['database']['path'], True)