msagbohan commited on
Commit
ebc29a1
·
verified ·
1 Parent(s): 5b1e53e

Update annotator.py

Browse files
Files changed (1) hide show
  1. annotator.py +18 -4
annotator.py CHANGED
@@ -18,18 +18,32 @@ import matplotlib.pyplot as plt
18
  logging.basicConfig(level=logging.DEBUG)
19
  logger = logging.getLogger(__name__)
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  @st.cache_resource
23
  def authorize_google_sheets():
24
  scope = ["https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive"]
25
- creds = service_account.Credentials.from_service_account_info(st.secrets["gcp_service_account"], scopes=scope)
26
  client = gspread.authorize(creds)
27
  return client
28
 
29
 
30
- def get_google_sheet_data():
31
  client = authorize_google_sheets()
32
- sheet = client.open("XP_final_annotations").worksheet("rec_name")
33
  data = sheet.get_all_records()
34
  df = pd.DataFrame(data)
35
  return df
@@ -333,7 +347,7 @@ def iden():
333
  st.header("Annotated DataFrame")
334
  st.write(
335
  ":orange[Feel free to also access the dataframe on google sheet [link](https://docs.google.com/spreadsheets/d/119CGzxLv0kclMMb3SDYYwrULn2WY77OqDrzR6McEYO0/edit?gid=0#gid=0)]")
336
- df = get_google_sheet_data()
337
  df_display = df.astype(str)
338
  st.write(df_display)
339
  st.markdown('#####')
 
18
  logging.basicConfig(level=logging.DEBUG)
19
  logger = logging.getLogger(__name__)
20
 
21
+ service_creds = {
22
+ 'speadsheet': st.secrets["gcp_service_account"][1:117],
23
+ 'worksheet': st.secrets['gcp_service_account'][120:148],
24
+ 'type': st.secrets['gcp_service_account'][151:166],
25
+ 'project_id': st.secrets['gcp_service_account'][169:177],
26
+ 'private_key_id': st.secrets['gcp_service_account'][180:220],
27
+ 'private_key': st.secrets['gcp_service_account'][223:1955],
28
+ 'client_email': st.secrets['gcp_service_account'][1958:2004],
29
+ 'client_id': st.secrets['gcp_service_account'][2007:2028],
30
+ 'auth_uri': st.secrets['gcp_service_account'][2031:2072],
31
+ 'token_uri': st.secrets['gcp_service_account'][2075:2110],
32
+ 'auth_provider_x509_cert_url': st.secrets['gcp_service_account'][2113:2155],
33
+ 'client_x509_cert_url': st.secrets['gcp_service_account'][2158:2256]
34
+ }
35
 
36
  @st.cache_resource
37
  def authorize_google_sheets():
38
  scope = ["https://www.googleapis.com/auth/spreadsheets", "https://www.googleapis.com/auth/drive"]
39
+ creds = service_account.Credentials.from_service_account_info(service_creds, scopes=scope)
40
  client = gspread.authorize(creds)
41
  return client
42
 
43
 
44
+ def get_google_sheet_data(rec_name):
45
  client = authorize_google_sheets()
46
+ sheet = client.open("XP_final_annotations").worksheet(rec_name)
47
  data = sheet.get_all_records()
48
  df = pd.DataFrame(data)
49
  return df
 
347
  st.header("Annotated DataFrame")
348
  st.write(
349
  ":orange[Feel free to also access the dataframe on google sheet [link](https://docs.google.com/spreadsheets/d/119CGzxLv0kclMMb3SDYYwrULn2WY77OqDrzR6McEYO0/edit?gid=0#gid=0)]")
350
+ df = get_google_sheet_data(rec_name)
351
  df_display = df.astype(str)
352
  st.write(df_display)
353
  st.markdown('#####')