Skip to content

Instantly share code, notes, and snippets.

James Sutton zeryx

Block or report user

Report or block zeryx

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View implicitReader.scala
import scala.reflect.runtime.universe._
import play.api.libs.json._
import scala.util.{Failure, Success, Try}
object AbstractAlgorithm {
trait AbstractAlgorithm[I, O] {
def apply(input: I): Try[O]
View AbstractAlgorithm.scala
package com.algorithmia.handler
import play.api.libs.json._
import scala.util.{Failure, Success, Try}
trait AbstractAlgorithm[I <: AnyVal, O <: AnyVal] {
def apply(input:I): Try[O]
def load(): Try[Unit] = Success(())
implicit def inputReader: Reads[I] = Try(implicitly[Reads[I]]) match {
case Failure(_) => Json.reads[I]
View ResponseHandler.scala
package com.algorithmia.handler
import scala.util.Try
case class ResponseHandler(){
val FIFOPATH = "/tmp/algoout"
zeryx /
Last active Oct 11, 2019
shim files to enable docker copy of dynamic files
import os
import sys
import json
from shutil import copy
from uuid import uuid4
def load_filenames_file(path):
with open(path) as f:
files = set(f.readlines())
return files
View dynamic_copy_caching.Dockerfile
FROM SOMEIMAGENAME as runner_intermediate
# We want to cache the following permanently, as these won't change frequently and take a very long time to move around and rebuild.
COPY --from=builder0 --chown=2222:2222 /some/artifact_dir /some/artifact_dir
RUN find /some/artifact_dir > /tmp/artifact_files_BEFORE
#This operation occurs on every build operation, therefore to increase perf we want all ops after this to be fast.
zeryx /
Created Sep 24, 2019
takes a pytorch resnet 18 model, strips off the last module and checks to make sure serialization still works properly.
import torch as th
from torchvision import models, transforms
from PIL import Image
import numpy as np
resnet18 = models.resnet18(pretrained=True)
model = th.nn.Sequential(*modules)
View gist:88ee0cb5d158a43db5e6abc20368b68d
import torch as th
from torchvision import models, transforms
from PIL import Image
import numpy as np
model = models.resnet18(pretrained=True)
class Identity(th.nn.Module):
def __init__(self):
super(Identity, self).__init__()
View 00check.log
$ cat algorithmia-r.Rcheck/00check.log
* using log directory ‘/home/zeryx/code/work/algorithmia-r.Rcheck’
* using R version 3.4.4 (2018-03-15)
* using platform: x86_64-pc-linux-gnu (64-bit)
* using session charset: UTF-8
* using option ‘--as-cran’
* checking for file ‘algorithmia-r/DESCRIPTION’ ... OK
* checking extension type ... Package
* this is package ‘algorithmia’ version ‘0.2.0’
* package encoding: UTF-8
View build.sbt
name := "algorithm-handler"
organization := ""
version := "1.0.0"
autoScalaLibrary := false
set -e
# When installing from CRAN, use this mirror as a default
echo "options(repos=structure(c(CRAN=\"$CRAN_MIRROR\")))" > ~/.Rprofile
# First install the latest CRAN packages system wide so it can populate the shared cache
You can’t perform that action at this time.