Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Alessio Civitillo committed Apr 30, 2021
0 parents commit b820d66
Show file tree
Hide file tree
Showing 49 changed files with 3,492 additions and 0 deletions.
149 changes: 149 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Linux
.bash_history

# VSCode
.vscode

# Azure
.azure

# Viadot
.config
.local
*.csv

# Prefect
config.toml

# MKDocs
desktop.ini
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 dyvenia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Viadot
A simple data ingestion library to guide data flows from some places to other places

## Getting Data from a Source

viadot supports few sources. For instance, the UK Carbon Intensity API does not require credentials.

```python
from viadot.sources.uk_carbon_intensity import UKCarbonIntensity
ukci = UKCarbonIntensity()
ukci.query("/intensity")
ukci.to_df()
```

The above code pulls the UK Carbon Insentity data from the external API to the local Pandas dataframe (df).

## Loading Data to a Source

TODO

## Running tests
```
run.sh
docker exec -it viadot_testing bash
cd tests/ && pytest .
```

## Running flows locally
```
run.sh
poetry shell
FLOW_NAME=supermetrics_to_azure_sql; python -m viadot.flows.$FLOW_NAME
```
45 changes: 45 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM prefecthq/prefect:latest-python3.8


# Add user
RUN useradd --create-home viadot && \
usermod -aG sudo viadot && \
find /usr/local/lib -type d -exec chmod 777 {} \; && \
find /usr/local/bin -type d -exec chmod 777 {} \;

RUN groupadd docker && \
usermod -aG docker viadot

# Release File Error
# https://stackoverflow.com/questions/63526272/release-file-is-not-valid-yet-docker
RUN echo "Acquire::Check-Valid-Until \"false\";\nAcquire::Check-Date \"false\";" | cat > /etc/apt/apt.conf.d/10no--check-valid-until

# System packages
RUN apt-get update && yes | apt-get install gcc unixodbc-dev build-essential curl graphviz sudo

# Azure CLI
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

# ODBC
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \
curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \
apt-get update && \
ACCEPT_EULA=Y apt-get install -y msodbcsql17 && \
ACCEPT_EULA=Y apt-get install -y mssql-tools && \
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc


# Python env
WORKDIR /code
COPY requirements.txt /code/
RUN pip install pip==20.0.2
RUN pip install -r requirements.txt


# Workdir
ENV USER viadot
ENV HOME="/home/$USER"
WORKDIR ${HOME}
USER ${USER}

EXPOSE 8000
6 changes: 6 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docker-compose build
docker system prune -f
echo ""
echo "Done. Press ENTER to exit."
echo ""
read
29 changes: 29 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: "3"

services:
viadot:
build:
context: ../
dockerfile: docker/Dockerfile
image: viadot
container_name: viadot_testing
volumes:
- ../:/home/viadot
tty: true
stdin_open: true
restart: "always"
viadot_docs:
build:
context: ../
dockerfile: docker/Dockerfile
image: viadot
container_name: viadot_docs
volumes:
- ../:/home/viadot
working_dir: /home/viadot
tty: true
stdin_open: true
ports:
- 8000:8000
command: "mkdocs serve"
restart: "always"
1 change: 1 addition & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker-compose up --remove-orphans
1 change: 1 addition & 0 deletions docs/about.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Some about file
10 changes: 10 additions & 0 deletions docs/howtos/flows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Using flows
Viadot flows subclass Prefect Flow class. We take this class, specify the tasks, and build the flow using the parameters provided at initialization time. See [Prefect Flow documentation](https://docs.prefect.io/api/0.12.6/core/flow.html#flow-2) for more information.

For instance, a `S3 to Redshift` flow would include the tasks necessary to insert S3 files into Redshift, and automate the generation of the flow. You only need to pass the required parameters.

For examples, check out the `examples` folder.


# Writing flows
For now, see the existing flows in `viadot/flows`.
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Welcome to MkDocs

For full documentation visit [mkdocs.org](https://www.mkdocs.org).

## Commands

* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.

## Project layout

mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
7 changes: 7 additions & 0 deletions docs/references/sources.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Reference

::: viadot.sources.uk_carbon_intensity.UKCarbonIntensity

::: viadot.sources.azure_sql.AzureSQL

::: viadot.sources.supermetrics.Supermetrics
1 change: 1 addition & 0 deletions docs/tutorials/placeholder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## TODO
23 changes: 23 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
site_name: Viadot Docs
nav:
- Home: index.md
- About: about.md
- Howtos:
- Flows: howtos/flows.md
- Tutorials:
- Tutorials: tutorials/placeholder.md
- References:
- Sources: references/sources.md
# - "Task library": references/sources.md
theme:
name: "material"
features:
- navigation.tabs
plugins:
- search
- mkdocstrings:
handlers:
python:
rendering:
show_root_heading: yes
dev_addr: "0.0.0.0:8000"
Loading

0 comments on commit b820d66

Please sign in to comment.