Skip to content

Instantly share code, notes, and snippets.

View andrewm4894's full-sized avatar
💭
Agentic

Andrew Maguire andrewm4894

💭
Agentic
View GitHub Profile
ARG BASE_CONTAINER=jupyter/scipy-notebook
FROM $BASE_CONTAINER
LABEL maintainer="[email protected]"
LABEL version="01"
USER $NB_UID
# install specific package versions i want to use here
RUN conda install --quiet --yes \
import json
from my_utils.os_utils import subprocess_execute
from my_dev.dev import hello_world
import pandas as pd
def run(event=dict(), context=dict()):
''' Function to be called by serverless lambda
'''
# make a dummy df to ensure pandas available to the lambda function
service: serverless-learn-lambda
provider:
name: aws
runtime: python3.6
region: us-west-2
stage: dev
role: arn:aws:iam::XXX:role/serverless-lambda
functions:
ARG BASE_CONTAINER=gcr.io/kubeflow-images-public/tensorflow-1.13.1-notebook-cpu:v0.5.0
FROM $BASE_CONTAINER
LABEL maintainer="[email protected]"
LABEL version="01"
RUN pip3 install git+https://github.com/andrewm4894/my_utils.git#egg=my_utils
RUN pip3 install kfp --upgrade
"""
GCP HTTP Cloud Function to handle github webhook events.
Some code stolen from here: https://github.com/carlos-jenkins/python-github-webhooks/blob/master/webhooks.py
"""
# -*- coding: utf-8 -*-
import hmac
import json
import datetime
service: handle-github-events
frameworkVersion: ">=1.2.0 <2.0.0"
package:
exclude:
- node_modules/**
- .gitignore
- .git/**
npm install serverless -g
serverless install -u https://github.com/serverless/examples/tree/master/google-python-simple-http-endpoint -n handle-github-events
cd handle-github-errors
npm i -D serverless-dotenv-plugin
npm install
def calc_batches(train_max: int, train_every: int, n: int) -> dict:
batches = dict()
# loop over up to as many records as you have
for batch in range(n):
# work out the start of the batch, with a max() to handle first batch
start = max(train_every * batch, 1)
# work out the end of the batch, with a min() to handle last batch
end = min(train_max+(train_every * batch), n)
# add batch info to the dictionary
batches[batch+1] = {"start": start, "end": end}
def calc_batches(train_min: int, train_max: int, train_every: int, n: int) -> dict:
batches = dict()
batch = 0
for row in range(1,n+1):
if row < train_min:
pass
elif row == train_min:
batches[batch] = dict(start=0, end=row)
elif row % train_every == 0:
batch += 1