Skip to content

Instantly share code, notes, and snippets.

View pingsutw's full-sized avatar
🏠
Working from home

Kevin Su pingsutw

🏠
Working from home
View GitHub Profile
@pingsutw
pingsutw / airflow_dag.py
Created July 26, 2023 20:04
Airflow example
from datetime import timedelta
from airflow import models
from airflow.contrib.operators import dataproc_operator
from airflow.operators.latest_only_operator import LatestOnlyOperator
from airflow.utils import trigger_rule
from chat_plugin import ChatNotifyOperator
from dataproc import hermes
from porch import settings as porch_settings, label
@pingsutw
pingsutw / sample.py
Created February 15, 2022 15:53
Read/Write by pandas and arrow
import pandas as pd
import pyarrow as pa
import pyarrow.parquet as pq
from fsspec.core import strip_protocol
from flytekitplugins.fsspec import FSSpecPersistence
from flytekitplugins.fsspec.pandas import get_storage_options
uri = "s3://open-compute-playground/arrow"
@pingsutw
pingsutw / experiment_openapi3.yaml
Created May 4, 2020 22:53
Submarine API definition - OpenAPI 3.0
openapi: 3.0.0
info:
description: The Submarine REST API allows you to create, list, and get experiments. The
API is hosted under the /v1/jobs route on the Submarine server. For example,
to list experiments on a server hosted at http://localhost:8080, access
http://localhost:8080/api/v1/jobs/
version: 1.0.0
title: Submarine Experiment API
termsOfService: http://swagger.io/terms/
contact:
@pingsutw
pingsutw / experiment.yaml
Last active May 4, 2020 18:56
Submarine Experiment spec - swagger 2.0
swagger: "2.0"
info:
description: "The Submarine REST API allows you to create, list, and get experiments. The API is hosted under the /v1/jobs route on the Submarine server. For example, to list experiments on a server hosted at http://localhost:8080, access http://localhost:8080/api/v1/jobs/"
version: "1.0.0"
title: "Submarine Experiment API"
termsOfService: "http://swagger.io/terms/"
contact:
email: "submarine-dev@submarine.apache.org"
license:
name: "Apache 2.0"
@pingsutw
pingsutw / swagger.yaml
Created April 28, 2020 10:24
Swagger YAML generated by submarine
swagger: '2.0'
info:
description: 'The Submarine REST API allows you to create, list, and get experiments. The API is hosted under the /v1/jobs route on the Submarine server. For example, to list experiments on a server hosted at http://localhost:8080, access http://localhost:8080/v1/jobs/status'
version: 1.0.0
title: ''
termsOfService: 'http://swagger.io/terms/'
contact:
email: submarine-dev@submarine.apache.org
license:
name: Apache 2.0
@pingsutw
pingsutw / submarineAPI.yaml
Last active April 28, 2020 08:42
Submarine Swagger API definition
swagger: "2.0"
info:
description: "The Submarine REST API allows you to create, list, and get experiments. The API is hosted under the /v1/jobs route on the Submarine server. For example, to list experiments on a server hosted at http://localhost:8080, access http://localhost:8080/api/v1/jobs/status"
version: "1.0.0"
title: "Submarine Job API"
termsOfService: "http://swagger.io/terms/"
contact:
email: "submarine-dev@submarine.apache.org"
license:
name: "Apache 2.0"
@pingsutw
pingsutw / tf_job_mnist.yaml
Created April 21, 2020 03:47
kubeflow - TensorFlow with init container
apiVersion: "kubeflow.org/v1"
kind: "TFJob"
metadata:
name: "mnist"
namespace: submarine
spec:
cleanPodPolicy: None
initContainers:
- name: init-mydb
image: busybox:1.28
@pingsutw
pingsutw / codejam.cpp
Last active April 5, 2020 06:45
Code Jam Template - Templates for Google Code Jam contest
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, y) for (__typeof(x) i = x; i <= y; i++)
#define repi(i, x, y) for (__typeof(x) i = x; i >= y; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(x, y) memset(x, y, sizeof(y))
@pingsutw
pingsutw / distributed_mnist.py
Created February 28, 2020 03:12
Distributed train mnist
# tensorflow 2 supported
# using MultiWorkerMirroredStrategy
# Need to install tf-nightly
# https://www.tensorflow.org/tutorials/distribute/multi_worker_with_keras
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import tensorflow_datasets as tfds
import tensorflow as tf
tfds.disable_progress_bar()
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.StringTokenizer;