Trigger DAG runs with Airflow REST API

Published June 24, 2019 in data - 0 Comments

This article and code is applicable to Airflow 1.10.13. Hopefully the REST API will mature as Airflow is developed further, and the authentication methods will be easier. The experimental REST API does not use the Airflow role-based users. Instead, it currently requires a SQLAlchemy models.User object whose data is saved in the database. The code […]

Tags: airflow , python

Useful Airflow on Kubernetes Features

Published June 7, 2019 in data , devops - 0 Comments

KubernetesExecutor The KubernetesExecutor sets up Airflow to run on a Kubernetes cluster. This executor runs task instances in pods created from the same Airflow Docker image used by the KubernetesExecutor itself, unless configured otherwise (more on that at the end). Getting Airflow deployed with the KubernetesExecutor to a cluster is not a trivial task. I […]

SageMaker lifecycle configuration time constraints

Published May 17, 2019 in data - 0 Comments

Creating AWS SageMaker Lifecycle configuration scripts to customize notebook instances beats installing packages and making other environment changes in notebook instances. One advantage is that the customization code doesn’t need to be copied from notebook to notebook. Another is that the lifecycle configurations are managed outside of and separately from notebook instances, and can be […]

Tags: aws , python

Customize Yellowbrick color palettes

Published January 16, 2019 in data - 0 Comments

I’m starting to experiment with the Yellowbrick machine learning visualizer tools to learn how to visualize models more effectively. The documentation is good, and getting started with the tools is pretty straightforward. I started to get bored with the default color palette after playing with some of the basic visualization examples in the documentation (more […]

New EC2 launch template version

Published January 8, 2019 in devops - 0 Comments

The AWS web console is not always intuitive to navigate and the documentation can be opaque. I recently had to edit an EC2 launch template, which is only possible by creating a new version and then making the new version the default used by the autoscale group. Here are the steps to create a new […]

Tags: aws

Python comprehension fun!

Published November 15, 2018 in programming - 0 Comments

List comprehensions are an extremely useful and optimized idiomatic Python language feature for manipulating and returning data stored in lists (or any iterable type). The Python 3 docs describe how to use basic and nested list comprehensions. Advanced nested list comprehensions If I wanted to clean some text by removing stop words and generate lists […]

Tags: python

Robust automatic retries in Celery tasks

Published October 22, 2018 in programming - 0 Comments

The Celery distributed task queue introduced retrying a failed task automatically for known exception types in version 4.0, and some very useful retry exponential backoff settings in version 4.2. Exponential backoff is beneficial because it spaces out retry requests in exponentially increasing intervals which can allow time to recover or restart. I turned off jitter […]

Tags: celery , docker , python

Attach to existing SageMaker job

Published July 30, 2018 in data - 0 Comments

The AWS SageMaker ntm_20newsgroups_topic_model example notebook is a simple to follow introduction to SageMaker’s pre-packaged Natural Language Processing (NLP) tools. The notebook demonstrates how to use the Neural Topic Model (NTM) algorithm to extract a set of topics from a sample usenet newsgroups dataset and visualize as word clouds. It also contains code demonstrating how […]

How to split a Pandas dataframe into training and test sets?

Published June 18, 2018 in data - 0 Comments

This question came up recently on a project where Pandas data needed to be fed to a TensorFlow classifier. In this case, we wanted to divide the dataframe using a random sampling. Frameworks like scikit-learn may have utilities to split data sets into training, test and cross-validation sets. For example, sklearn.model_selection.train_test_split split numpy arrays or […]

Docker Compose for integration testing

Published June 17, 2018 in devops - 0 Comments

For integration tests with few external dependencies that don’t require much orchestration beyond networking Docker containers and setting up environment variables, Docker Compose is a simple and easy to manage solution for building, running and tearing down tests. This Flask application example is typical. The project’s multistage Dockerfile defines both the service and test images: […]

Tags: ci , docker