PhDFlo commited on
Commit
60c5fba
·
1 Parent(s): d08ff62

Init var in function

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -51,8 +51,8 @@ def create_custom_config(
51
 
52
  # Function to compute Chai1 inference
53
  def compute_Chai1(
54
- fasta_file: Optional[str] = None,
55
- inference_config_file: Optional[str] = None,
56
  ):
57
  """Compute a Chai1 simulation.
58
 
@@ -65,31 +65,33 @@ def compute_Chai1(
65
  with app.run():
66
 
67
  force_redownload = False
68
- output_dir = None
69
- run_id = None
70
 
71
  print("🧬 checking inference dependencies")
72
  download_inference_dependencies.remote(force=force_redownload)
73
 
74
- if fasta_file is None:
 
75
  fasta_file = here / "inputs" / "chai1_default_input.fasta"
76
  print(f"🧬 running Chai inference on {fasta_file}")
 
 
77
  fasta_content = Path(fasta_file).read_text()
78
 
79
- if inference_config_file is None:
 
80
  inference_config_file = here / "inputs" / "chai1_quick_inference.json"
81
  print(f"🧬 loading Chai inference config from {inference_config_file}")
82
  inference_config = json.loads(Path(inference_config_file).read_text())
83
 
84
- if run_id is None:
85
- run_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8] # short id
86
  print(f"🧬 running inference with {run_id=}")
87
 
88
  results = chai1_inference.remote(fasta_content, inference_config, run_id)
89
 
90
- if output_dir is None:
91
- output_dir = Path("./results")
92
- output_dir.mkdir(parents=True, exist_ok=True)
93
 
94
  print(f"🧬 saving results to disk locally in {output_dir}")
95
  for ii, (scores, cif) in enumerate(results):
 
51
 
52
  # Function to compute Chai1 inference
53
  def compute_Chai1(
54
+ fasta_file: Optional[str] = "",
55
+ inference_config_file: Optional[str] = "",
56
  ):
57
  """Compute a Chai1 simulation.
58
 
 
65
  with app.run():
66
 
67
  force_redownload = False
 
 
68
 
69
  print("🧬 checking inference dependencies")
70
  download_inference_dependencies.remote(force=force_redownload)
71
 
72
+ # Define fasta file
73
+ if not fasta_file:
74
  fasta_file = here / "inputs" / "chai1_default_input.fasta"
75
  print(f"🧬 running Chai inference on {fasta_file}")
76
+ print("titi")
77
+ print(fasta_file)
78
  fasta_content = Path(fasta_file).read_text()
79
 
80
+ # Define inference config file
81
+ if not inference_config_file:
82
  inference_config_file = here / "inputs" / "chai1_quick_inference.json"
83
  print(f"🧬 loading Chai inference config from {inference_config_file}")
84
  inference_config = json.loads(Path(inference_config_file).read_text())
85
 
86
+ # Generate a unique run ID
87
+ run_id = hashlib.sha256(uuid4().bytes).hexdigest()[:8] # short id
88
  print(f"🧬 running inference with {run_id=}")
89
 
90
  results = chai1_inference.remote(fasta_content, inference_config, run_id)
91
 
92
+ # Define output directory
93
+ output_dir = Path("./results")
94
+ output_dir.mkdir(parents=True, exist_ok=True)
95
 
96
  print(f"🧬 saving results to disk locally in {output_dir}")
97
  for ii, (scores, cif) in enumerate(results):