kbberendsen commited on
Commit
55a5cb3
1 Parent(s): 38bec10

update cache and improve calc function

Browse files
Files changed (1) hide show
  1. app.py +3 -14
app.py CHANGED
@@ -17,22 +17,14 @@ folder_name = 'cache'
17
  # Create a Path object for the folder
18
  folder_path = current_directory / folder_name
19
 
20
- # Check if the folder exists
21
  if folder_path.exists() and folder_path.is_dir():
22
  print(f"The folder '{folder_name}' exists.")
23
  else:
24
  print(f"The folder '{folder_name}' does not exist.")
25
 
26
-
27
- script_dir = os.path.dirname(os.path.abspath(__file__))
28
- print(script_dir)
29
- cache_folder = 'cache'
30
- #cache_dir = os.path.join(script_dir, cache_folder)
31
- cache_dir = Path(__file__).parent / "cache"
32
- print(cache_dir)
33
  ff1.Cache.enable_cache(folder_path)
34
 
35
-
36
  app_ui = ui.page_fluid(
37
  ui.div(
38
  ui.input_select(
@@ -48,8 +40,6 @@ app_ui = ui.page_fluid(
48
  def server(input, output, session):
49
  @reactive.Calc
50
  def get_data():
51
-
52
-
53
  f1_session = ff1.get_session(2023, input.track(), 'R')
54
  f1_session.load()
55
 
@@ -63,15 +53,14 @@ def server(input, output, session):
63
  points = np.array([x, y]).T.reshape(-1, 1, 2)
64
  segments = np.concatenate([points[:-1], points[1:]], axis=1)
65
  gear = tel['nGear'].to_numpy().astype(float)
66
- return lap, tel, x, y, points, segments, gear
67
 
68
  @output
69
  @render.plot
70
  def gear():
71
- lap = get_data().lap
72
- tel = get_data().tel
73
  points = get_data().points
74
  segments = get_data().segments
 
75
 
76
 
77
  cmap = cm.get_cmap('Paired')
 
17
  # Create a Path object for the folder
18
  folder_path = current_directory / folder_name
19
 
20
+ # Check if the cache folder exists
21
  if folder_path.exists() and folder_path.is_dir():
22
  print(f"The folder '{folder_name}' exists.")
23
  else:
24
  print(f"The folder '{folder_name}' does not exist.")
25
 
 
 
 
 
 
 
 
26
  ff1.Cache.enable_cache(folder_path)
27
 
 
28
  app_ui = ui.page_fluid(
29
  ui.div(
30
  ui.input_select(
 
40
  def server(input, output, session):
41
  @reactive.Calc
42
  def get_data():
 
 
43
  f1_session = ff1.get_session(2023, input.track(), 'R')
44
  f1_session.load()
45
 
 
53
  points = np.array([x, y]).T.reshape(-1, 1, 2)
54
  segments = np.concatenate([points[:-1], points[1:]], axis=1)
55
  gear = tel['nGear'].to_numpy().astype(float)
56
+ return points, segments, gear
57
 
58
  @output
59
  @render.plot
60
  def gear():
 
 
61
  points = get_data().points
62
  segments = get_data().segments
63
+ gear = get_data().gear
64
 
65
 
66
  cmap = cm.get_cmap('Paired')