Skip to content

Commit

Permalink
Implement v0.1.0-rc1 (#1)
Browse files Browse the repository at this point in the history
* `flit init`

* Init

* Update

* Update

* Update

* Update

* Update

* Format
  • Loading branch information
yu-iskw authored Mar 1, 2022
1 parent 9751730 commit 1612542
Show file tree
Hide file tree
Showing 70 changed files with 32,406 additions and 1 deletion.
16 changes: 16 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

* @yu-iskw
41 changes: 41 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Publish (pypi)

on:
release:
types:
- created

jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
- name: Install Flit
if: steps.cache.outputs.cache-hit != 'true'
run: bash dev/setup.sh
- name: Publish
env:
# SEE https://packaging.python.org/en/latest/specifications/pypirc/?highlight=token#using-a-pypi-token
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: bash dev/publish.sh "pypi"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
39 changes: 39 additions & 0 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test publish (testpypi)

on:
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.9"
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-publish
- name: Install Flit
if: steps.cache.outputs.cache-hit != 'true'
run: bash dev/setup.sh
- name: Test publish
env:
# SEE https://packaging.python.org/en/latest/specifications/pypirc/?highlight=token#using-a-pypi-token
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.TESTPYPI_API_TOKEN }}
run: bash dev/publish.sh "testpypi"
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Test python

on:
pull_request:
paths:
- 'pyproject.toml'
- 'dbt_artifacts_parser/**/*.py'
- 'tests/**/*.py'
push:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
fail-fast: false

defaults:
run:
shell: bash

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-test
- name: Install Flit
if: steps.cache.outputs.cache-hit != 'true'
run: bash dev/setup.sh
- name: Lint
if: ${{ matrix.python-version != '3.6' }}
run: bash dev/lint_python.sh
- name: Test
run: bash dev/test_python.sh
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ MANIFEST
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
!dbt_artifacts_parser/parsers/manifest
!dbt_artifacts_parser/resources/manifest

# Installer logs
pip-log.txt
Expand Down
10 changes: 10 additions & 0 deletions .pypirc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[distutils]
index-servers =
pypi
testpypi

[pypi]
repository=https://upload.pypi.org/legacy/

[testpypi]
repository=https://test.pypi.org/legacy/
2 changes: 2 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[style]
based_on_style = google
8 changes: 8 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
exclude .git
exclude .gitignore
exclude tests
exclude .style.yapf
exclude Makefile
exclude pylintrc
exclude __pycache__
exclude dbt_artifacts_parser/resources
45 changes: 45 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Set up an environment
.PHONEY: setup
setup:
bash ./dev/setup.sh

# Check all the coding style.
.PHONY: lint
lint: lint-shell lint-python

# Check the coding style for the shell scripts.
.PHONY: lint-shell
lint-shell:
shellcheck ./dev/*.sh

# Check the coding style for the python files.
.PHONY: lint-python
lint-python:
bash ./dev/lint_python.sh

# Format source codes
format: format-python

# Format python codes
format-python:
bash ./dev/format_python.sh

# Run the unit tests.
.PHONEY: test
test:
bash ./dev/test_python.sh

# Build the package
build: clean format test
flit build

clean:
bash ./dev/clean.sh

# Publish to pypi
publish:
bash ./dev/publish.sh "pypi"

# Publish to testpypi
test-publish:
bash ./dev/publish.sh "testpypi"
155 changes: 154 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,155 @@
[![Test python](https://github.com/yu-iskw/dbt-artifacts-parser/actions/workflows/test.yml/badge.svg)](https://github.com/yu-iskw/dbt-artifacts-parser/actions/workflows/test.yml)
<a href="https://pypi.org/project/dbt-artifacts-parser" target="_blank">
<img src="https://img.shields.io/pypi/v/dbt-artifacts-parser?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
<a href="https://pypi.org/project/dbt-artifacts-parser" target="_blank">
<img src="https://img.shields.io/pypi/pyversions/dbt-artifacts-parser.svg?color=%2334D058" alt="Supported Python versions">
</a>


# dbt-artifacts-parser
A dbt artifacts parser in python
This is a dbt artifacts parse in python.
It enables us to deal with `catalog.json`, `manifest.json`, `run-results.json` and `sources.json` as python objects.

## Installation

```bash
pip install -U dbt-artifacts-parser
```

## Example

### Parse catalog.json
```python
import yaml

# parse any version of catalog.json
from dbt_artifacts_parser.parser import parse_catalog

with open("path/to/catalog.json", "r") as fp:
catalog_dict = yaml.safe_load(fp)
catalog_obj = parse_catalog(catalog=catalog_dict)

# parse catalog.json v1
from dbt_artifacts_parser.parser import parse_catalog_v1

with open("path/to/catalog.json", "r") as fp:
catalog_dict = yaml.safe_load(fp)
catalog_obj = parse_catalog_v1(catalog=catalog_dict)
```

### Parse manifest.json

```python
import yaml

# parse any version of manifest.json
from dbt_artifacts_parser.parser import parse_manifest

with open("path/to/manifest.json", "r") as fp:
manifest_dict = yaml.safe_load(fp)
manifest_obj = parse_manifest(manifest=manifest_dict)

# parse manifest.json v1
from dbt_artifacts_parser.parser import parse_manifest_v1

with open("path/to/manifest.json", "r") as fp:
manifest_dict = yaml.safe_load(fp)
manifest_obj = parse_manifest_v1(manifest=manifest_dict)

# parse manifest.json v2
from dbt_artifacts_parser.parser import parse_manifest_v2

with open("path/to/manifest.json", "r") as fp:
manifest_dict = yaml.safe_load(fp)
manifest_obj = parse_manifest_v2(manifest=manifest_dict)

# parse manifest.json v3
from dbt_artifacts_parser.parser import parse_manifest_v3

with open("path/to/manifest.json", "r") as fp:
manifest_dict = yaml.safe_load(fp)
manifest_obj = parse_manifest_v3(manifest=manifest_dict)

# parse manifest.json v4
from dbt_artifacts_parser.parser import parse_manifest_v4

with open("path/to/manifest.json", "r") as fp:
manifest_dict = yaml.safe_load(fp)
manifest_obj = parse_manifest_v4(manifest=manifest_dict)
```

### Parse run-results.json

```python
import yaml

# parse any version of run-results.json
from dbt_artifacts_parser.parser import parse_run_results

with open("path/to/run-resultsjson", "r") as fp:
run_results_dict = yaml.safe_load(fp)
run_results_obj = parse_run_results(run_results=run_results_dict)

# parse run-results.json v1
from dbt_artifacts_parser.parser import parse_run_results_v1

with open("path/to/run-results.json", "r") as fp:
run_results_dict = yaml.safe_load(fp)
run_results_obj = parse_run_results_v1(run_results=run_results_dict)

# parse run-results.json v2
from dbt_artifacts_parser.parser import parse_run_results_v2

with open("path/to/run-results.json", "r") as fp:
run_results_dict = yaml.safe_load(fp)
run_results_obj = parse_run_results_v2(run_results=run_results_dict)

# parse run-results.json v3
from dbt_artifacts_parser.parser import parse_run_results_v3

with open("path/to/run-results.json", "r") as fp:
run_results_dict = yaml.safe_load(fp)
run_results_obj = parse_run_results_v3(run_results=run_results_dict)

# parse run-results.json v4
from dbt_artifacts_parser.parser import parse_run_results_v4

with open("path/to/run-results.json", "r") as fp:
run_results_dict = yaml.safe_load(fp)
run_results_obj = parse_run_results_v4(run_results=run_results_dict)
```

### Parse sources.json

```python
import yaml

# parse any version of sources.json
from dbt_artifacts_parser.parser import parse_sources

with open("path/to/sources.json", "r") as fp:
sources_dict = yaml.safe_load(fp)
sources_obj = parse_sources(sources=sources_dict)

# parse sources.json v1
from dbt_artifacts_parser.parser import parse_sources_v1

with open("path/to/sources.json", "r") as fp:
sources_dict = yaml.safe_load(fp)
sources_obj = parse_sources_v1(sources=sources_dict)

# parse sources.json v2
from dbt_artifacts_parser.parser import parse_sources_v2

with open("path/to/sources.json", "r") as fp:
sources_dict = yaml.safe_load(fp)
sources_obj = parse_sources_v2(sources=sources_dict)

# parse sources.json v3
from dbt_artifacts_parser.parser import parse_sources_v3

with open("path/to/sources.json", "r") as fp:
sources_dict = yaml.safe_load(fp)
sources_obj = parse_sources_v3(sources=sources_dict)
```
20 changes: 20 additions & 0 deletions dbt_artifacts_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# 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
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""
A dbt artifacts parser in python
"""
__version__ = "0.1.0-rc1"
Loading

0 comments on commit 1612542

Please sign in to comment.