import io import modal stub = modal.Stub(image=modal.DebianSlim().pip_install(["prophet"])) @stub.function def run(): import pandas as pd from prophet import Prophet from matplotlib import pyplot df = pd.read_csv('https://raw.githubusercontent.com/facebook/prophet/main/examples/example_wp_log_peyton_manning.csv') df.head() m = Prophet() m.fit(df) future = m.make_future_dataframe(periods=365) future.tail() forecast = m.predict(future) forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail() fig1 = m.plot(forecast) buf = io.BytesIO() pyplot.savefig(buf) return buf.getvalue() if __name__ == "__main__": with stub.run(): data = run() with open("prophet.png", "wb") as f: f.write(data)