-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch.py
49 lines (33 loc) · 1.15 KB
/
batch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import gc
import json
import os
from datetime import datetime
from loguru import logger
from h2ox.ai.inference import local_inference
from h2ox.ai.slackbot import SlackMessenger
def main():
today = datetime.now()
token = os.environ.get("SLACKBOT_TOKEN")
target = os.environ.get("SLACKBOT_TARGET")
if token is not None and target is not None:
slackmessenger = SlackMessenger(
token=token,
target=target,
name="H2OX-PIPELINE :: ",
)
else:
slackmessenger = None
msg, code = w2w_inference(today, slackmessenger)
logger.info("made it here")
return f"Done inference {today.isoformat()}", 200
def w2w_inference(today: datetime, slackmessenger: SlackMessenger):
# step 2-> rerun inference and post results
basin_networks = json.loads(os.environ.get("BASIN_NETWORKS"))
msg = local_inference(today, basin_networks)
if slackmessenger is not None:
slackmessenger.message(f"W2W ::: inference: {json.dumps(msg)}")
return f"w2w inference {today.isoformat()}", 200
if __name__ == "__main__":
main()
logger.info("made it there")
gc.collect()