Skip to content

Commit 182ba8c

Browse files
authored
Merge pull request #288 from macrocosm-os/staging
2 parents 7671be4 + 6632a28 commit 182ba8c

File tree

7 files changed

+379
-326
lines changed

7 files changed

+379
-326
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ We use a combination of `conda` and `poetry` to manage our environments. It is v
6969
git clone https://github.com/macrocosm-os/folding.git
7070
cd folding
7171

72-
conda create --name folding python3.11
72+
conda create --name folding python=3.11
7373
bash install.sh
7474
```
7575

folding/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from .protocol import JobSubmissionSynapse
22
from .validators.protein import Protein
33

4-
__version__ = "1.2.3"
4+
__version__ = "1.3.0"
55
version_split = __version__.split(".")
66
__spec_version__ = (
77
(10000 * int(version_split[0]))

folding/store.py

+43-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
import json
12
import os
23
import random
3-
import string
4-
import json
54
import sqlite3
6-
from typing import List
5+
import string
6+
from dataclasses import asdict, dataclass
7+
from datetime import datetime
78
from queue import Queue
8-
from datetime import datetime, timedelta
9-
from dataclasses import dataclass, asdict
9+
from typing import List
1010

1111
import numpy as np
1212
import pandas as pd
13+
import requests
14+
from atom.epistula.epistula import Epistula
1315

1416
DB_DIR = os.path.join(os.path.dirname(__file__), "db")
1517

@@ -22,6 +24,7 @@ def __init__(self, db_path=DB_DIR, table_name="protein_jobs"):
2224
self.table_name = table_name
2325
os.makedirs(self.db_path, exist_ok=True)
2426
self.db_file = os.path.join(self.db_path, "jobs.db")
27+
self.epistula = Epistula()
2528

2629
self.init_db()
2730

@@ -218,6 +221,41 @@ def __repr__(self):
218221
df = pd.read_sql_query(f"SELECT * FROM {self.table_name}", conn)
219222
return f"{self.__class__.__name__}\n{df.__repr__()}"
220223

224+
def upload_job(
225+
self,
226+
pdb: str,
227+
ff: str,
228+
box: str,
229+
water: str,
230+
hotkeys: list,
231+
system_kwargs: dict,
232+
hotkey,
233+
gjp_address: str,
234+
):
235+
"""Upload a job to the database."""
236+
237+
body = {
238+
"pdb_id": pdb,
239+
"hotkeys": hotkeys,
240+
"system_config": {
241+
"ff": ff,
242+
"box": box,
243+
"water": water,
244+
"system_kwargs": system_kwargs,
245+
},
246+
"em_s3_link": "s3://path/to/em",
247+
"priority": 1,
248+
"organic": False
249+
}
250+
body_bytes = self.epistula.create_message_body(body)
251+
headers = self.epistula.generate_header(hotkey=hotkey, body=body_bytes)
252+
253+
response = requests.post(
254+
f"http://{gjp_address}/jobs", headers=headers, data=body_bytes
255+
)
256+
if response.status_code != 200:
257+
raise ValueError(f"Failed to upload job: {response.text}")
258+
221259

222260
# Keep the Job and MockJob classes as they are, they work well with both implementations
223261
@dataclass

folding/utils/config.py

+6
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ def add_validator_args(cls, parser):
432432
"5CQ9KNHy9qvRGhLWeV37agEpmLckSgMXzbZWEEXwbupSCTQy",
433433
],
434434
)
435+
parser.add_argument(
436+
"--neuron.gjp_address",
437+
type=str,
438+
help="The IP address and port of the global job pool.",
439+
default="174.138.3.61:8030",
440+
)
435441

436442

437443
def config(cls):

neurons/validator.py

+13
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@ async def add_job(self, job_event: dict[str, Any], uids: List[int] = None) -> bo
249249
system_kwargs=job_event["system_kwargs"],
250250
event=job_event,
251251
)
252+
try:
253+
self.store.upload_job(
254+
pdb=job_event["pdb_id"],
255+
ff=job_event["ff"],
256+
water=job_event["water"],
257+
box=job_event["box"],
258+
hotkeys=selected_hotkeys,
259+
system_kwargs=job_event["system_kwargs"],
260+
hotkey=self.wallet.hotkey,
261+
gjp_address=self.config.neuron.gjp_address,
262+
)
263+
except Exception as e:
264+
logger.warning(f"Error uploading job: {e}")
252265

253266
return True
254267
else:

0 commit comments

Comments
 (0)