File size: 1,153 Bytes
fa2f208
 
 
7f62ff3
 
 
 
fa2f208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests
import os

# Dynamically pull the port from the environment (will be 7860 on Hugging Face)
# or fall back to 8000 if you run it locally.
PORT = os.environ.get("PORT", "8000")
BASE_URL = f"http://127.0.0.1:{PORT}"

class PvRecNetAPI:
    @staticmethod
    def upload_dataset(file_bytes, filename):
        files = {'file': (filename, file_bytes, 'text/csv')}
        response = requests.post(f"{BASE_URL}/upload-data", files=files)
        response.raise_for_status()
        return response.json()

    @staticmethod
    def run_prediction(dataset_id):
        response = requests.post(f"{BASE_URL}/predict", json={"dataset_id": dataset_id})
        response.raise_for_status()
        return response.json()

    @staticmethod
    def get_moi(dataset_id):
        response = requests.post(f"{BASE_URL}/compute-moi", json={"dataset_id": dataset_id})
        response.raise_for_status()
        return response.json()

    @staticmethod
    def get_allele_freq(dataset_id):
        response = requests.post(f"{BASE_URL}/allele-frequency", json={"dataset_id": dataset_id})
        response.raise_for_status()
        return response.json()