Skip to content

Instantly share code, notes, and snippets.

View aaronpolhamus's full-sized avatar
💭
🤘🤓🤘

Aaron Polhamus aaronpolhamus

💭
🤘🤓🤘
View GitHub Profile
@aaronpolhamus
aaronpolhamus / map_clsloc.txt
Created May 12, 2016 01:21
Image net classes + labels
n02119789 1 kit_fox
n02100735 2 English_setter
n02110185 3 Siberian_husky
n02096294 4 Australian_terrier
n02102040 5 English_springer
n02066245 6 grey_whale
n02509815 7 lesser_panda
n02124075 8 Egyptian_cat
n02417914 9 ibex
n02123394 10 Persian_cat
@aaronpolhamus
aaronpolhamus / redis_handlers.py
Created August 9, 2020 02:06
task locking with redis + celery
"""Task locking with redis in celery is hard, and good examples are tough to come by. This is the approach that's
worked for me, based on great work that other folks have posted:
* https://breadcrumbscollector.tech/what-is-celery-beat-and-how-to-use-it-part-2-patterns-and-caveats/
* http://loose-bits.com/2010/10/distributed-task-locking-in-celery.html
* https://redis.io/topics/distlock
This isn't polished,but hopefully it's useful. To verify it in our local test env we register the following test task in
our definitions file:
*** definitions.py ***
# Credits:
# [1] https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html (CUDA)
# [2] https://www.if-not-true-then-false.com/2015/fedora-nvidia-guide/ (Drivers)
yum install nano
# In /etc/sysconfig/selinux update to SELINUX=disabled (takes down firewall and speeds up downloads)
# [1] Install kernel headers
sudo dnf install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
# [1] Docker installation: https://docs.docker.com/install/linux/docker-ce/fedora/
# [2] Docker compose: https://github.com/Yelp/docker-compose/blob/master/docs/install.md
# [3] NVIDIA docker installation: https://github.com/NVIDIA/nvidia-docker/issues/553#issuecomment-381075335
# [4] Tensorflow docker installation: https://www.tensorflow.org/install/docker
# [1] install dnf-plugins-core
sudo dnf -y install dnf-plugins-core
# [1] setup stable repository
sudo dnf config-manager \
@aaronpolhamus
aaronpolhamus / vgg_net.py
Created April 1, 2016 22:42
Adaptation of VGG net for Keras, with 128x128 greyscale images and 196 target classes
import os
import sys
import json
import model_control
from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation, Flatten
from keras.layers import Convolution2D, MaxPooling2D
from keras.optimizers import SGD
import numpy as np
from numpy import loadtxt, asarray
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
from datetime import datetime
from airflow.models import DAG
from airflow.operators.python_operator import PythonOperator
DAG = DAG(
dag_id='scheduler_test_dag',
start_date=datetime(2017, 9, 9, 4, 0, 0, 0), #..EC2 time. Equal to 11pm hora México
max_active_runs=1,
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@aaronpolhamus
aaronpolhamus / api_demo.py
Created June 16, 2017 00:55
Python API client demo for Google Drive SDK
#!/usr/bin/env python
from __future__ import print_function
import os
from apiclient.discovery import build
from httplib2 import Http
from oauth2client import file, client, tools
try:
import argparse