This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import tempfile | |
import os | |
import threading | |
class ClientS3: | |
def __init__(self, bucket_name:str, profile_name:str, local_dir:str=None) -> None: | |
self.bucket_name = bucket_name | |
self.profile_name = profile_name | |
if local_dir is None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import google.auth.transport.requests | |
import google.oauth2.id_token | |
import threading | |
import requests | |
from google.cloud import tasks_v2 | |
def create_http_task_with_token( | |
project: str, | |
location: str, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from googleapiclient.discovery import build | |
from googleapiclient.http import MediaFileUpload | |
from googleapiclient.errors import HttpError | |
from oauth2client.service_account import ServiceAccountCredentials | |
class GoogleDriveService(object): | |
""" | |
A class used to represent an GoogleDrive service for uploading files | |
gdrive_credentials.json must be in same folder, if not |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# Calling: python3 mysqldump_replace_column.py '/original/test.sql' 8 'NULL' | |
# Will replace de 8th column with NULL in a new file/location: '/edited/test_chunk_00001.sql' | |
import sys | |
import re | |
import csv | |
import glob | |
import os | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps: | |
- id: "docker-build" | |
timeout: 1500s | |
name: "gcr.io/cloud-builders/docker" | |
args: ["build", "-t", "us-central1-docker.pkg.dev/${_PROJECT_ID}/${_REPOSITORY}/${_IMAGE}", "."] | |
- id: "push-docker-image" | |
name: "gcr.io/cloud-builders/docker" | |
args: ["push", "us-central1-docker.pkg.dev/${_PROJECT_ID}/${_REPOSITORY}/${_IMAGE}"] | |
waitFor: ["docker-build"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def truncate_varchar(df, db=None, table=None): | |
from sqlalchemy import MetaData | |
meta = MetaData() | |
meta.reflect(only=[table], resolve_fks=False, views = False, bind=db.getEngine()) | |
datatable = meta.tables[table] | |
types = [str(c.type).lower() for c in datatable.columns] | |
names = [str(c.name).lower() for c in datatable.columns] | |
dict_tables = dict(zip(names, types)) | |
dict_chars = {k:v for k,v in dict_tables.items() if 'char' in v} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(didint grant permission to my user, thats why everything is runing with sudo) | |
=========================================================================== | |
NEED TO AUTH FIRST, SET THE PROJECT AND CONFIGURE DOCKER IN RIGHT LOCATION | |
sudo gcloud auth login | |
sudo gcloud config set project 'PROJECT' | |
sudo gcloud auth configure-docker LOCATION_ARTIFACT | |
=========================================================================== |