Skip to content

Instantly share code, notes, and snippets.

import hashlib
import sys
from module import download_model_locally
def check_model_md5(model_name, api_production_artifact_md5):
"""Ref: https://stackoverflow.com/a/21565932/"""
"""This function will download the model """
download_model_locally_to(model_name)
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness-ml-application
name: liveness-ml-application
spec:
containers:
- name: ml_application
image: internal_registry/ml_application
apiVersion: v1
kind: Pod
metadata:
labels:
test: liveness-ml-application
name: liveness-ml-application
spec:
containers:
- name: ml_application
image: internal_registry/ml_application
docker build -f dags/docker_job/Dockerfile -t docker_image_task . && \
docker-compose up -d
docker-compose up airflow-init
@fclesio
fclesio / docker-job.py
Created May 22, 2021 13:44
DockerOperator with Docker Compose - Sleep Statements
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.docker_operator import DockerOperator
from airflow.operators.python_operator import BranchPythonOperator
from airflow.operators.dummy_operator import DummyOperator
default_args = {
'owner' : 'airflow',
'description' : 'Use of the DockerOperator',
@fclesio
fclesio / docker-job.py
Last active May 22, 2021 13:44
DockerOperator with Docker Compose - Print Statements
from datetime import datetime, timedelta
from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.docker_operator import DockerOperator
from airflow.operators.python_operator import BranchPythonOperator
from airflow.operators.dummy_operator import DummyOperator
default_args = {
'owner' : 'airflow',
'description' : 'Use of the DockerOperator',
@fclesio
fclesio / pandas_2_fasttext.py
Created April 21, 2021 21:47
Pandas to Fasttext
import pandas as pd
import fasttext
df = pd.read_csv('B2W-Reviews01.csv', sep=';')
df['label'] = '__label__' + df['site_category_lv1']
df = df.sample(n=10000)
df[['label', 'review_text']].to_csv('gfjakhsdgkfjhgsd.txt', index=None, header=None)
@fclesio
fclesio / airflow.cfg
Created January 25, 2021 11:07
Airflow configuration file with [logging] section
[core]
# The folder where your airflow pipelines live, most likely a
# subfolder in a code repository
# This path must be absolute
dags_folder = /usr/local/airflow/dags
# The folder where airflow should store its log files
# This path must be absolute
base_log_folder = /usr/local/airflow/logs
@fclesio
fclesio / log_config.py
Created January 25, 2021 11:05
Custom logging in Airflow.
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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