This file contains hidden or 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
| swagger: "2.0" | |
| servers: | |
| - url: https://www.kaggle.com/api/v1 | |
| description: Kaggle API | |
| variables: | |
| host: | |
| default: www.kaggle.com | |
| basePath: | |
| default: /api/v1 | |
| info: |
This file contains hidden or 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
| #!/bin/bash | |
| GITHUB_TOKEN=<DO-NOT-COMMIT> | |
| SWAP_SIZE="16G" | |
| # install pyenv to install alternative python versions | |
| sudo apt-get update | |
| sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \ | |
| libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \ | |
| libffi-dev liblzma-dev libedit-dev git -y |
This file contains hidden or 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
| from typing import Optional | |
| import pydantic | |
| from pydantic_sqlalchemy import sqlalchemy_to_pydantic | |
| from app.core import models | |
| class AllOptional(pydantic.main.ModelMetaclass): | |
| def __new__(mcs, name, bases, namespaces, **kwargs): |
This file contains hidden or 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
| .PHONY: all prepare-dev venv lint test run shell clean build install docker | |
| SHELL=/bin/bash | |
| VENV_NAME?=venv | |
| VENV_BIN=$(shell pwd)/${VENV_NAME}/bin | |
| VENV_ACTIVATE=. ${VENV_BIN}/activate | |
| PYTHON=${VENV_BIN}/python3 | |
| FLASK=${VENV_BIN}/flask |
This file contains hidden or 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
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo gpg --dearmor -o /usr/share/keyrings/githubcli-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
| sudo apt update | |
| sudo apt install gh |
This file contains hidden or 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
| ssh-keygen -t ed25519 -C "sellanes.jose@gmail.com" |
This file contains hidden or 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
| sudo apt-get update; sudo apt-get install make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev libedit-dev git | |
| curl https://pyenv.run | bash | |
| echo "export PATH=\$PATH:/home/agustin/.pyenv/bin" >> ./.bashrc | |
| exec $SHELL |
This file contains hidden or 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
| from pydantic import BaseModel | |
| from sqlalchemy.dialects.mysql import (NUMERIC, DECIMAL, DOUBLE, REAL, FLOAT, INTEGER, BIGINT, MEDIUMINT, TINYINT, | |
| SMALLINT, BIT, TIME, TIMESTAMP, DATETIME, YEAR, TEXT, TINYTEXT, MEDIUMTEXT, | |
| LONGTEXT, VARCHAR, CHAR, NVARCHAR, NCHAR, TINYBLOB, MEDIUMBLOB, LONGBLOB) | |
| class Column(BaseModel): | |
| autoincrement: bool | |
| comment: Optional[str] | |
| default: Optional[Any] | |
| name: str |
This file contains hidden or 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
| # pks is a dictionary with table names as keys and primary keys columns names as values | |
| # if SQLAlqemy cannot find the primary keys from the table metadata, specifying the keys | |
| # enables the ORM to generate the classes and relationships | |
| def automap_session(engine: Engine, pks: Dict[str, str]) -> Tuple[Dict[str, BaseModel], Session]: | |
| metadata = MetaData() | |
| metadata.reflect(engine, schema=SCHEMA) | |
| cols = {t.name: {c.name: c for c in t.columns._all_columns} for t in metadata.tables.values()} | |
| for t, c in pks.items(): | |
| cols[t][c].primary_key = True |
This file contains hidden or 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
| create_engine(f'snowflake://{user}:{password}@{account}/{table}', | |
| connect_args={'options': f'-csearch_path={schema}'}) |
NewerOlder