Skip to content

Instantly share code, notes, and snippets.

View betatim's full-sized avatar
🤠
Not my first rodeo

Tim Head betatim

🤠
Not my first rodeo
View GitHub Profile
import time
# try cupy as well
import numpy as np
try:
import cunumeric as cunp
except RuntimeError as e:
pass
import cupy as cp
$ ./install.py --cuda
Verbose build is off
Using python lib and version: /nvme/0/thead/miniconda/envs/legate-test/lib/libpython3.10.so, 3.10.9
Performing a clean build to accommodate build isolation.
Processing /home/nfs/thead/git/legate.core-jjwilke
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.22 in /nvme/0/thead/miniconda/envs/legate-test/lib/python3.10/site-packages (from legate.core==22.7.0.dev0+249.ga08d963) (1.24.2)
Building wheels for collected packages: legate.core
class Mixin:
def _foo_and_set_attr(self, a):
r = self._original_foo(a)
# Now massage `self`, maybe convert some attributes
# or some other work
self.a = int(a)
return r
def __init_subclass__(cls, **kwargs):
cls._original_foo = cls.foo
@betatim
betatim / find_classes.py
Last active December 9, 2022 07:41
Find all the classes in a module and its sub-modules
import inspect
import importlib
import sklearn
def find_classes(module, base=None):
if base is None:
base = module.__name__
classes = []
# Defining the API of an engine
class BaseEngine:
def __init__(self, estimator):
self.estimator = estimator
def accepts(self, X, y=None, sample_weight=None):
"""Decide if this engine wants to handle this request.
Based on the information available the engine can decide
if it wants to handle this request or not. To (not) handle the
import time
import numpy as np
import cupy as cp
import sklearn
from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs
from sklearn.model_selection import train_test_split
a = np.array_api.arange(10)
b = cupy.arange(10)
# use all the arrays, without ever having to care what kind they are
for x in (a, b):
xp = x.__array_namespace__()
print(xp.abs(x))
@betatim
betatim / blackhole.py
Created November 16, 2021 15:59
A module from which you can import anything
# The weird thing is that normally you can't get anything out of a black hole
#
# Try it with things like:
#
# from blackhole import X, Y, Z
# import blackhole
def __getattr__(*args, **kwargs):
pass
@betatim
betatim / flags.py
Last active October 23, 2021 10:03
Simple toy to experiment with "feature flagging"
import functools
import inspect
import random
def variation(*, default, public=False):
def decorator(f):
if not f.__name__.endswith("_variation"):
raise RuntimeError(f"Variation '{f.__name__}' name does not end with '_variation'.")
@betatim
betatim / jupyterhub.log
Created July 29, 2020 16:38
Log of the jupyterhub pod on OVH
[E 200729 16:28:09 launcher:101] Error accessing Hub API (using https://hub-binder.mybinder.ovh/hub/api/users/binder-examples-requirements-vqaeghik): HTTP 503: Service Unavailable
[E 200729 16:28:10 web:2250] 503 GET /health (34.66.138.193) 9.42ms
[E 200729 16:28:11 web:2250] 503 GET /health (34.66.138.193) 6.97ms
[I 200729 16:28:12 web:2250] 200 GET /about (51.68.77.249) 1.66ms
[I 200729 16:28:17 web:2250] 200 GET /about (51.68.77.249) 1.69ms
[I 200729 16:28:18 web:2250] 200 GET /metrics (10.2.2.70) 10.05ms
[I 200729 16:28:22 web:2250] 200 GET /about (51.68.77.249) 1.89ms
[E 200729 16:28:25 launcher:101] Error accessing Hub API (using https://hub-binder.mybinder.ovh/hub/api/users/binder-examples-requirements-vqaeghik): HTTP 503: Service Unavailable
[E 200729 16:28:25 launcher:171] Error creating user binder-examples-requirements-vqaeghik: HTTP 503: Service Unavailable
b'Service Unavailable'