In this example, we will use the Chronos model: amazon/chronos-t5-tiny(opens in a new tab). Chronos is a family of pretrained time series forecasting models based on language model architectures. A time series is transformed into a sequence of tokens via scaling and quantization, and a language model is trained on these tokens using the cross-entropy loss. Once trained, probabilistic forecasts are obtained by sampling multiple future trajectories given the historical context. Chronos models have been trained on a large corpus of publicly available time series data, as well as synthetic data generated using Gaussian processes. For simplicity, we will use Zero-shot forecasting, which refers to the ability of models to generate forecasts from unseen datasets.
import requests
import sys
import json
def process(argument):
headers = {'Content-Type': 'application/json'}
url = f"http://inference:8000/inference/{argument}"
response = requests.get(url, headers=headers)
return response.text
if __name__ == "__main__":
# Your code logic with the parsed argument goes here
try:
if len(sys.argv) < 5:
value = json.dumps({"error": f"Not enough arguments provided: {len(sys.argv)}, expected 4 arguments: topic_id, blockHeight, blockHeightEval, default_arg"})
else:
topic_id = sys.argv[1]
blockHeight = sys.argv[2]
blockHeightEval = sys.argv[3]
default_arg = sys.argv[4]
response_inference = process(argument=default_arg)
response_dict = {"infererValue": response_inference}
value = json.dumps(response_dict)
except Exception as e:
value = json.dumps({"error": {str(e)}})
print(value)
6. Updating the Docker
Modifying Dockerfile
FROM alloranetwork/allora-inference-base:latest
RUN pip install requests
COPY main.py /app/
Create new Dockerfile_inference
FROM amd64/python:3.9-buster
WORKDIR /app
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install --upgrade pip \
&& pip install -r requirements.txt
EXPOSE 8000
ENV NAME sample
# Run gunicorn when the container launches and bind port 8000 from app.py
CMD ["gunicorn", "-b", ":8000", "app:app"]
7. Update config
Update your hex_coded_pk:
allorad keys export faceworker --keyring-backend test --unarmored-hex --unsafe