Skip to content

Instantly share code, notes, and snippets.

View hamelsmu's full-sized avatar
💻
Always learning.

Hamel Husain hamelsmu

💻
Always learning.
View GitHub Profile
@hamelsmu
hamelsmu / example_nb_flow.py
Last active February 2, 2022 06:02
Four outerbounds blog post
from metaflow import step, current, FlowSpec, Parameter, card
from mymodel import train_model
class NBFlow(FlowSpec):
"A toy example of using the notebook card."
@step
def start(self):
# Train a model, save the results in `model_results`
self.model_results = train_model(...)
@hamelsmu
hamelsmu / pytorch_lightning_metaflow.md
Last active January 18, 2022 19:48
Feedback on @pytorch distributed training re: Metaflow

Feedback on @pytorch_parallel

Related to [metaflow #907](Netflix/metaflow#907 and the related docs draft

1. Developer Ergonimics

To use the feature, the user must learn a brand new way of doing foreach. This adds a high degree of congntive load, as the user must remember that for this particular use case and this use case only, they need to use self.next(..., num_parallel=...).

The api makes it very unclear where the parallelization is happening. For example, pytorch_lightning.trainer has an argument gpus=-1, which means that it will use all available gpus. In this case, what does num_parallel add to this? The user has lots of cognitive overload to have to reason about where and what kind of parallelization is happening.

@hamelsmu
hamelsmu / upload.py
Created May 26, 2021 03:51
How to upload data to Azure Blob Store
import os
from azure.storage.blob import BlobServiceClient
blob_service_client = BlobServiceClient.from_connection_string(os.getenv('AZURE_STORAGE_CONNECTION_STRING'))
with open('gh_repo_topics.parquet', 'rb') as data:
blob_client = container_client.upload_blob(name="sample_data/gh_repo_topics.parquet", data=data, overwrite=True)
####### Downloading files ##########
f = container_client.download_blob("sample_data/gh_repo_topics.parquet")
@hamelsmu
hamelsmu / fastai-azureml.ipynb
Last active May 22, 2021 16:15
fastai example doesn't work
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hamelsmu
hamelsmu / start_vm.sh
Created April 30, 2021 00:16
Quickly Spin Up a Deep Learning Rig on Google Cloud
export IMAGE_FAMILY="pytorch-latest-gpu"
export ZONE="us-west1-b"
export INSTANCE_NAME="dl-rig"
gcloud compute instances create $INSTANCE_NAME \
--zone=$ZONE \
--image-family=$IMAGE_FAMILY \
--image-project=deeplearning-platform-release \
--maintenance-policy=TERMINATE \
--accelerator="type=nvidia-tesla-v100,count=2" \
@hamelsmu
hamelsmu / draft-mode.ipynb
Last active April 2, 2021 06:03
What is the payload field for determining the draft status of a PR for GitHub Actions?
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hamelsmu
hamelsmu / sanity.ipynb
Last active March 13, 2021 14:01
GitHub Notification Sanity With `ghapi`
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hamelsmu
hamelsmu / lp.ipynb
Last active February 25, 2021 15:11
Linear Program with Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@hamelsmu
hamelsmu / nbdev_jekyll.py
Last active April 18, 2023 04:25
Helper Script to use nbdev remote theme
#!/usr/bin/env python
# coding: utf-8
from fastcore.all import *
from shutil import rmtree
import yaml
rm=['_includes','_layouts','css','fonts','js','licenses','tooltips.json','Gemfile','Gemfile.lock']
raw='https://raw.githubusercontent.com/fastai/nbdev_template/master/docs/'