Files changed (4) hide show
  1. api.py +7 -4
  2. app.py +7 -2
  3. ecosystem.config.js +12 -12
  4. utils.py +30 -14
api.py CHANGED
@@ -8,8 +8,7 @@ import utils
8
  import pandas as pd
9
  import uvicorn
10
 
11
- from classes import Productivity, Throughput
12
-
13
 
14
 
15
  # Global variables (saves time on loading data)
@@ -32,7 +31,6 @@ def load_data():
32
  data_all = utils.preload_data()
33
 
34
  data_24h = data_all[(pd.Timestamp.now() - data_all['updated_at'].apply(lambda x: pd.Timestamp(x)) < pd.Timedelta('1 days'))]
35
-
36
  reload_timestamp = datetime.datetime.now().strftime('%D %T')
37
 
38
  print(f'Reloaded data at {reload_timestamp}')
@@ -63,7 +61,12 @@ def productivity_metrics():
63
  Get the productivity metrics
64
  """
65
 
66
- return Productivity(all_time=utils.get_productivity(data_all), last_24h=utils.get_productivity(data_24h))
 
 
 
 
 
67
 
68
 
69
  @app.get("/throughput", response_model=Throughput)
 
8
  import pandas as pd
9
  import uvicorn
10
 
11
+ from classes import Productivity, ProductivityData, Throughput
 
12
 
13
 
14
  # Global variables (saves time on loading data)
 
31
  data_all = utils.preload_data()
32
 
33
  data_24h = data_all[(pd.Timestamp.now() - data_all['updated_at'].apply(lambda x: pd.Timestamp(x)) < pd.Timedelta('1 days'))]
 
34
  reload_timestamp = datetime.datetime.now().strftime('%D %T')
35
 
36
  print(f'Reloaded data at {reload_timestamp}')
 
61
  Get the productivity metrics
62
  """
63
 
64
+ # Unpack the metrics using the correct keys
65
+ result = utils.get_productivity(df_all=data_all, df_24h=data_24h)
66
+ all_time = ProductivityData(**result['all_time'])
67
+ last_24h = ProductivityData(**result['last_24h'])
68
+
69
+ return Productivity(all_time=all_time, last_24h=last_24h)
70
 
71
 
72
  @app.get("/throughput", response_model=Throughput)
app.py CHANGED
@@ -34,10 +34,15 @@ productivity_all = requests.get(f'{BASE_URL}/productivity').json()
34
  productivity = productivity_all['all_time']
35
  productivity_24h = productivity_all['last_24h']
36
 
 
 
 
37
 
38
  m1, m2 = st.columns(2)
39
- m1.metric('Unique proteins folded', f'{productivity["unique_folded"]:,.0f}', delta=f'{productivity_24h["unique_folded"]:,.0f} (24h)')
40
- m2.metric('Total jobs completed', f'{productivity["total_completed_jobs"]:,.0f}', delta=f'{productivity_24h["total_completed_jobs"]:,.0f} (24h)')
 
 
41
  # m3.metric('Total simulation steps', f'{productivity.get("total_md_steps"):,.0f}', delta=f'{productivity_24h.get("total_md_steps"):,.0f} (24h)')
42
 
43
  # st.markdown('<br>', unsafe_allow_html=True)
 
34
  productivity = productivity_all['all_time']
35
  productivity_24h = productivity_all['last_24h']
36
 
37
+ # st.write(productivity_all)
38
+ # # st.write(productivity)
39
+ # st.write(productivity_24h)
40
 
41
  m1, m2 = st.columns(2)
42
+
43
+ m1.metric('Unique proteins folded', f'{productivity.get("unique_folded", 0):,.0f}', delta=f'{productivity_24h.get("unique_folded", 0):,.0f} (24h)')
44
+ m2.metric('Total jobs completed', f'{productivity.get("total_completed_jobs", 0):,.0f}', delta=f'{productivity_24h.get("total_completed_jobs", 0):,.0f} (24h)')
45
+
46
  # m3.metric('Total simulation steps', f'{productivity.get("total_md_steps"):,.0f}', delta=f'{productivity_24h.get("total_md_steps"):,.0f} (24h)')
47
 
48
  # st.markdown('<br>', unsafe_allow_html=True)
ecosystem.config.js CHANGED
@@ -1,14 +1,14 @@
1
  module.exports = {
2
- apps: [
3
- {
4
- name: 'hf-dashboard-api',
5
- script: '/home/spunion/Sn25/api.py',
6
- interpreter: '/home/spunion/Sn25/venv/bin/python',
7
- autorestart: true,
8
- watch: false,
9
- env: {
10
- NODE_ENV: 'production',
11
- },
12
  },
13
- ],
14
- };
 
 
1
  module.exports = {
2
+ apps: [
3
+ {
4
+ name: 'hf-dashboard-api',
5
+ script: '/home/spunion/Sn25/api.py',
6
+ interpreter: '/home/spunion/Sn25/venv/bin/python',
7
+ autorestart: true,
8
+ watch: false,
9
+ env: {
10
+ NODE_ENV: 'production',
 
11
  },
12
+ },
13
+ ],
14
+ };
utils.py CHANGED
@@ -153,21 +153,37 @@ def get_data_transferred(df, unit='GB'):
153
  }
154
 
155
 
156
- def get_productivity(df):
157
-
158
- # Estimate the number of unique pdbs folded using our heuristic
159
- unique_folded = len(df.pdb_id.value_counts())
160
- # Estimate the total number of jobs completed using our heuristic
161
- completed_jobs = len(df[df.active == False])
162
-
163
- total_historical_run_updates = df.active.isna().sum()
164
- total_historical_completed_jobs = total_historical_run_updates//10 # this is an estimate based on minimum number of updates per pdb
165
-
166
-
167
- return {
168
- 'unique_folded': unique_folded,
169
- 'total_completed_jobs': (completed_jobs + total_historical_completed_jobs).item(),
170
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
 
172
  def get_leaderboard(df, ntop=10, entity_choice='identity'):
173
 
 
153
  }
154
 
155
 
156
+ def get_productivity(df_all, df_24h):
157
+ result = {
158
+ 'all_time': {
159
+ 'unique_folded': 0,
160
+ 'total_completed_jobs': 0
161
+ },
162
+ 'last_24h': {
163
+ 'unique_folded': 0,
164
+ 'total_completed_jobs': 0
165
+ }
 
 
 
 
166
  }
167
+ if df_all is not None:
168
+ unique_folded_all = len(df_all.pdb_id.value_counts())
169
+ completed_jobs_all = len(df_all[df_all.active == False])
170
+
171
+ total_historical_run_updates = df_all.active.isna().sum()
172
+ total_historical_completed_jobs = total_historical_run_updates//10 # this is an estimate based on minimum number of updates per pdb
173
+
174
+ result['all_time'].update({
175
+ 'unique_folded': unique_folded_all,
176
+ 'total_completed_jobs': (completed_jobs_all + total_historical_completed_jobs).item(),
177
+ })
178
+
179
+ if df_24h is not None:
180
+ completed_jobs_24h = df_24h[df_24h['updated_count'] >= 10]
181
+ unique_completed_jobs_24h = completed_jobs_24h.drop_duplicates(subset=['pdb_id'], keep='first')
182
+ result['last_24h'].update({
183
+ 'unique_folded': len(unique_completed_jobs_24h),
184
+ 'total_completed_jobs': len(completed_jobs_24h)
185
+ })
186
+ return result
187
 
188
  def get_leaderboard(df, ntop=10, entity_choice='identity'):
189