samsl commited on
Commit
8267a35
·
1 Parent(s): 3ca7567

pass HF token to structure features

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -22,7 +22,9 @@ from loguru import logger
22
  from matplotlib.cm import ScalarMappable
23
  from matplotlib.colors import Normalize
24
 
25
- from rocketshp import RocketSHP, load_sequence, load_structure
 
 
26
  from rocketshp.network import (
27
  build_allosteric_network,
28
  calculate_centrality,
@@ -149,7 +151,9 @@ def predict_rocketshp(
149
  raise gr.Error("Sequence input is required for the selected model.")
150
 
151
  struct_features = None
152
- seq_features = load_sequence(sequence, device=device, HF_TOKEN=token)
 
 
153
 
154
  else:
155
  if structure_file is None:
@@ -209,9 +213,12 @@ def predict_rocketshp(
209
  logger.info(len(structure))
210
  logger.info(structure[:3])
211
 
212
- struct_features = load_structure(structure, device=device)
 
 
 
213
  sequence = str(to_sequence(structure)[0][0])
214
- seq_features = load_sequence(sequence, device=device)
215
 
216
  # Make predictions
217
  with torch.no_grad():
@@ -429,18 +436,22 @@ def check_user_access(oauth_token: gr.OAuthToken | None):
429
  raise gr.Error("Please log in to use this Space")
430
 
431
  token = oauth_token.token
 
432
 
433
  try:
434
  # Try to access a file from your private repo
435
  api = HfApi(token=token)
 
436
 
437
  # Test access by trying to get repo info
438
- api.repo_info(
439
  repo_id="EvolutionaryScale/esm3-sm-open-v1",
440
  repo_type="model", # or "dataset" or "space"
441
  token=token,
442
  )
443
 
 
 
444
  return (
445
  True,
446
  token,
 
22
  from matplotlib.cm import ScalarMappable
23
  from matplotlib.colors import Normalize
24
 
25
+ from rocketshp import RocketSHP
26
+ from rocketshp import load_sequence as get_sequence_features
27
+ from rocketshp import load_structure as get_structure_features
28
  from rocketshp.network import (
29
  build_allosteric_network,
30
  calculate_centrality,
 
151
  raise gr.Error("Sequence input is required for the selected model.")
152
 
153
  struct_features = None
154
+
155
+ logger.info("Loading sequence features...")
156
+ seq_features = get_sequence_features(sequence, device=device, HF_TOKEN=token)
157
 
158
  else:
159
  if structure_file is None:
 
213
  logger.info(len(structure))
214
  logger.info(structure[:3])
215
 
216
+ logger.info("Loading structure features...")
217
+ struct_features = get_structure_features(
218
+ structure, device=device, HF_TOKEN=token
219
+ )
220
  sequence = str(to_sequence(structure)[0][0])
221
+ seq_features = get_sequence_features(sequence, device=device, HF_TOKEN=token)
222
 
223
  # Make predictions
224
  with torch.no_grad():
 
436
  raise gr.Error("Please log in to use this Space")
437
 
438
  token = oauth_token.token
439
+ print(token)
440
 
441
  try:
442
  # Try to access a file from your private repo
443
  api = HfApi(token=token)
444
+ print(api)
445
 
446
  # Test access by trying to get repo info
447
+ repo_info = api.repo_info(
448
  repo_id="EvolutionaryScale/esm3-sm-open-v1",
449
  repo_type="model", # or "dataset" or "space"
450
  token=token,
451
  )
452
 
453
+ print(repo_info)
454
+
455
  return (
456
  True,
457
  token,