mathiasleys commited on
Commit
e819afa
•
1 Parent(s): edab474

Implement retry mechanism

Browse files
Files changed (2) hide show
  1. helpers/thompson_sampling.py +3 -0
  2. requirements.txt +2 -1
helpers/thompson_sampling.py CHANGED
@@ -6,6 +6,7 @@ import random
6
  import matplotlib.pyplot as plt
7
  import numpy as np
8
  import streamlit as st
 
9
 
10
  import config as cfg
11
 
@@ -61,6 +62,7 @@ class ThompsonSampler:
61
  def create_price_plot(self):
62
  fig = plt.figure()
63
  plt.xlabel("Price")
 
64
  plt.yticks(color='w')
65
 
66
  price_distr = [self.calc_optimal_price(post_demand, sample=False)
@@ -119,6 +121,7 @@ class ThompsonSampler:
119
  self.calc_optimal_price(posterior_sample, sample=True)
120
  self.create_plots(highlighted_sample=posterior_sample)
121
 
 
122
  def run(self):
123
  if st.session_state.latent_elasticity != self.latent_elasticity:
124
  self.update_elasticity()
 
6
  import matplotlib.pyplot as plt
7
  import numpy as np
8
  import streamlit as st
9
+ from tenacity import retry, stop_after_attempt, wait_fixed
10
 
11
  import config as cfg
12
 
 
62
  def create_price_plot(self):
63
  fig = plt.figure()
64
  plt.xlabel("Price")
65
+ plt.xlim(0,20)
66
  plt.yticks(color='w')
67
 
68
  price_distr = [self.calc_optimal_price(post_demand, sample=False)
 
121
  self.calc_optimal_price(posterior_sample, sample=True)
122
  self.create_plots(highlighted_sample=posterior_sample)
123
 
124
+ @retry(stop=stop_after_attempt(5), wait=wait_fixed(0.25))
125
  def run(self):
126
  if st.session_state.latent_elasticity != self.latent_elasticity:
127
  self.update_elasticity()
requirements.txt CHANGED
@@ -1,3 +1,4 @@
1
  pymc3==3.11.5
2
  streamlit==1.10.0
3
- sympy==1.10.1
 
 
1
  pymc3==3.11.5
2
  streamlit==1.10.0
3
+ sympy==1.10.1
4
+ tenacity==8.1.0