Skip to content

Instantly share code, notes, and snippets.

View jcrist's full-sized avatar

Jim Crist-Harif jcrist

View GitHub Profile
@jcrist
jcrist / sparse_demo.ipynb
Created October 12, 2018 19:22
Sparse Tensor Decomposition with Tensorly
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jcrist
jcrist / honeycomb.py
Created May 15, 2020 20:32
Using honeycomb with starlette
import beeline
from starlette.exceptions import HTTPException
from starlette.datastructures import Headers
class HoneycombMiddleware:
def __init__(self, app):
self.app = app
@jcrist
jcrist / simplepickle.py
Last active May 29, 2020 17:55
A simple version of pickle
import pickle
import struct
class Memo(object):
def __init__(self):
self.kv = {}
def put(self, item):
ind = self.kv[id(item)] = len(self.kv)
@jcrist
jcrist / README.md
Created July 10, 2020 22:22
SciPy Sprints 2020

Dask SciPy Sprints 2020

Hello! Welcome to the Dask sprints for SciPy 2020.

Getting started contributing

Here's a few links for getting started contributing:

  • Our contributor guide is here. This should cover
@jcrist
jcrist / vis.py
Created March 15, 2017 22:51
Simple visualization of dask graph pipelines.
import os
import graphviz
from dask.optimize import key_split
from dask.dot import _get_display_cls
from dask.core import get_dependencies
def node_key(s):
if isinstance(s, tuple):
@jcrist
jcrist / structs.py
Created August 20, 2020 17:25
Python struct class
import typing
import inspect
def _extract_attributes(bases, attrs):
arg_fields = {}
kwarg_fields = {}
existing_slots = set()
# Walk up the bases, validating and merging defaults
@jcrist
jcrist / bench.py
Created September 6, 2020 15:50
Quickle Structs benchmark
In [3]: from typing import NamedTuple
In [4]: from quickle import Struct
In [5]: from dataclasses import dataclass
In [6]: class PointTuple(NamedTuple):
...: x: int
...: y: int
...:
@jcrist
jcrist / kubernetes_run_config.py
Created December 16, 2020 17:54
Prefect Example using KubernetesRun
from prefect import Flow
from prefect.run_configs import KubernetesRun
from prefect.storage import Docker
with Flow("kubernetes-example") as flow:
# Add tasks to flow here...
# Run on Kubernetes with a custom resource configuration
flow.run_config = KubernetesRun(cpu_request=2, memory_request="4Gi")
# Store the flow in a docker image
@jcrist
jcrist / kubernetes_job_environment.py
Last active December 16, 2020 17:57
Prefect Example using KubernetesJobEnviornment
from prefect import Flow
from prefect.environments.execution import KubernetesJobEnvironment
from prefect.environments.storage import Docker
with Flow("kubernetes-example") as flow:
# Add tasks to flow here...
# Run on Kubernetes using a custom job specification
# This was needed to do even simple things like increase
# the job resource limits