This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Note – this is not a bash script (some of the steps require reboot) | |
| # I named it .sh just so Github does correct syntax highlighting. | |
| # | |
| # This is also available as an AMI in us-east-1 (virginia): ami-cf5028a5 | |
| # | |
| # The CUDA part is mostly based on this excellent blog post: | |
| # http://tleyden.github.io/blog/2014/10/25/cuda-6-dot-5-on-aws-gpu-instance-running-ubuntu-14-dot-04/ | |
| # Install various packages | |
| sudo apt-get update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import contextlib | |
| import OpenSSL.crypto | |
| import os | |
| import requests | |
| import ssl | |
| import tempfile | |
| @contextlib.contextmanager | |
| def pfx_to_pem(pfx_path, pfx_password): | |
| ''' Decrypts the .pfx file to be used with requests. ''' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_n_results_dumb(q): | |
| r = requests.get('http://www.google.com/search', | |
| params={'q': q, | |
| "tbs": "li:1"}) | |
| r.raise_for_status() | |
| soup = bs4.BeautifulSoup(r.text) | |
| s = soup.find('div', {'id': 'resultStats'}).text | |
| if not s: | |
| return 0 | |
| m = re.search(r'([0-9,]+)', s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from matplotlib import pyplot | |
| import random | |
| import time | |
| pyplot.style.use("ggplot") | |
| now = time.time() | |
| def generate_user(censor=now): | |
| # Pick some point in time the user was created | |
| t_created = t = now - random.random() * 1e7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import io | |
| import sys | |
| import modal | |
| stub = modal.Stub( | |
| image=modal.Image.debian_slim() | |
| .apt_install(["git"]) | |
| .pip_install( | |
| [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Note: this assumes you have a notebook locally named my_notebook.ipynb | |
| import modal | |
| stub = modal.Stub( | |
| image=modal.DebianSlim().pip_install(["papermill", "ipykernel"]), | |
| mounts=[modal.Mount(local_file="my_notebook.ipynb", remote_dir="/root")], | |
| ) | |
| @stub.function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import modal | |
| stub = modal.Stub( | |
| image=modal.Image.debian_slim().pip_install(["datasets", "torch", "transformers"]) | |
| ) | |
| class Predictor: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == "__main__": | |
| secret = modal.Secret({"FOO": os.environ["FOO"]}) | |
| else: | |
| secret = modal.Secret.from_name("baz") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import subprocess | |
| import sys | |
| import tempfile | |
| import modal | |
| stub = modal.Stub() | |
| stub.sv = modal.SharedVolume().persist("valhalla") | |
| image = modal.DockerhubImage("valhalla/valhalla:run-latest", setup_commands=["apt-get update", "apt-get install -y python3-pip"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
NewerOlder