Skip to content

Instantly share code, notes, and snippets.

@alongubkin
alongubkin / S3ServiceAccount.ts
Last active October 26, 2022 15:58
Create Kubernetes ServiceAccount with access to S3 using Pulumi
import * as pulumi from '@pulumi/pulumi';
import * as aws from '@pulumi/aws';
import * as k8s from '@pulumi/kubernetes';
export interface S3ServiceAccountArgs {
oidcProvider: aws.iam.OpenIdConnectProvider;
namespace: pulumi.Input<string>;
readOnly: pulumi.Input<boolean>;
}
@alongubkin
alongubkin / TraefikRoute.ts
Last active June 30, 2022 23:12
Create Traefik IngressRoute with strip prefix & add trailing slash using Pulumi
import * as pulumi from '@pulumi/pulumi';
import * as k8s from '@pulumi/kubernetes';
export interface TraefikRouteArgs {
namespace: pulumi.Input<string>;
prefix: pulumi.Input<string>;
service: pulumi.Input<k8s.core.v1.Service>;
}
export default class TraefikRoute extends pulumi.ComponentResource {
@metric("median")
def median_metric(data: DataFrame) -> Optional[Union[float, int]]:
"""Computes the median of a data series.
Args:
data: Data series.
Returns:
DataFrame median value or None if DataFrame is empty.
"""
series = df_to_series(data)
if len(series) == 0:
@alongubkin
alongubkin / log_predictions.js
Created October 14, 2021 15:58
Log predictions to Aporia from Node.js
import fetch from "node-fetch";
const APORIA_TOKEN = "<TOKEN>";
async function logPredictions(data) {
const query = `
mutation LogPredict(
$modelId: String!,
$modelVersion: String!,
$environment: String!,
@alongubkin
alongubkin / get_models_and_versions
Created September 6, 2021 16:39
Get models & versions through GraphQL API
curl --request POST \
--url <APORIA_HOST>/v1/tenant-hasura/v1/graphql \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--data \
'{
"query": "query { models { id name versions { id name } } }",
"variables": {}
}'
@alongubkin
alongubkin / Dockerfile
Last active June 7, 2021 23:23
Dockerfile + Makefile + GitHub Action
FROM python:3.8-slim
WORKDIR /my_model
STOPSIGNAL SIGINT
ENV LISTEN_PORT 80
# System dependencies
RUN apt update && apt install -y libgomp1
RUN pip3 install poetry
@alongubkin
alongubkin / iris.csv
Created June 7, 2021 21:47
LightGBM example
sepal.length sepal.width petal.length petal.width variety
5.1 3.5 1.4 .2 Setosa
4.9 3 1.4 .2 Setosa
4.7 3.2 1.3 .2 Setosa
4.6 3.1 1.5 .2 Setosa
5 3.6 1.4 .2 Setosa
5.4 3.9 1.7 .4 Setosa
4.6 3.4 1.4 .3 Setosa
5 3.4 1.5 .2 Setosa
4.4 2.9 1.4 .2 Setosa
@alongubkin
alongubkin / untitled0.ipynb
Created March 17, 2021 15:12
Untitled0.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.