Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: major codebase overhaul #52

Merged
merged 22 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
9 changes: 9 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[run]
omit = tests/**,**/__init__.py
relative_files = True

[report]
show_missing = True

[html]
directory = coverage_html_report
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[flake8]
exclude = env,venv,indexers-wip,migrations,migrations-wip,schemas-wip
21 changes: 21 additions & 0 deletions .github/workflows/safety-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Python Safety Check

on:
push:
branches:
- '*'
pull_request:
branches: [ "main" ]

env:
DEP_PATH: requirements.txt

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out master
uses: actions/checkout@master

- name: Security vulnerabilities scan
uses: aufdenpunkt/python-safety-check@master
35 changes: 35 additions & 0 deletions .github/workflows/tests-merged.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Unit Tests (on PR)

on:
push:
branches: [ "main" ]

permissions:
contents: read
pull-requests: write

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
set -o pipefail
python -m pytest tests | tee pytest-coverage.txt
62 changes: 62 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Unit Tests (on PR)

on:
pull_request:
branches: [ "main" ]

permissions:
contents: read
pull-requests: write

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
set -o pipefail
python -m pytest tests | tee pytest-coverage.txt
- name: Pytest coverage comment
id: coverageComment
uses: MishaKav/pytest-coverage-comment@main
with:
pytest-coverage-path: ./pytest-coverage.txt
- name: Check the output coverage
run: |
echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}"
echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}"
echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}"
echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}"
echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}"
echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}"
echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}"
echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}"
echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"
- name: Create the Badge
uses: schneegans/[email protected]
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 1e9f82572ceec742044c9ce6f230d275
filename: test-coverage.json
label: Coverage Report
message: ${{ steps.coverageComment.outputs.coverage }}
color: ${{ steps.coverageComment.outputs.color }}
namedLogo: python
38 changes: 33 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
.python-version
workspace.code-workspace
metadata/*.json
images/*.png
.ipynb_checkpoints/
# repo
build
temp
package.zip
.env
.test.yaml
.vscode
test/data/*
output

# venv
env
venv
.env
.venv

# python
__pycache__
.pytest_cache
*.pyc
.ipynb_checkpoints/
.DS_Store
.idea
.idea/*
*.code-workspace
.python-version

# tests
.coverage
.coverage.*
coverage.xml

*metadata/*.json
*images/*.png
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]
name: isort (python)
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: local
hooks:
- id: autoflake
name: autoflake
entry: autoflake
language: python
"types": [python]
require_serial: true
args:
- "--in-place"
- "--expand-star-imports"
- "--remove-duplicate-keys"
- "--remove-unused-variables"
- "--remove-all-unused-imports"
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ As of v2.0.0, nft-generator-py will use the argparse library in order to support
1. Install requirements: `python3 -m pip install -r requirements.txt`
2. Make a configuration JSON file. See the configuration section below for specifications.
3. Add layer files into the `/images` folder.
4. Run the command `python3 generate.py --amount AMOUNT --config CONFIG`

where:
4. Run the command `python3 generate.py --amount AMOUNT --config CONFIG` where:
1. `AMOUNT` is the amount of images to generate
2. `CONFIG` is the path pointing to a `.json` file containing valid program configuration.

Expand Down Expand Up @@ -53,8 +51,8 @@ As of v2.0.0, nft-generator-py will use the argparse library in order to support
}
```

The `config` object is a dict that contains configuration instructions that can be changed to produce different outputs when running the program. Within metadata files, tokens are named using the configuration's `name` parameter, and described using the `description` parameter.
- In ascending order, tokenIds are appended to the `name` resulting in NFT metadata names such as NFT #0001.
The `config` object is a dict that contains configuration instructions that can be changed to produce different outputs when running the program. Within metadata files, tokens are named using the configuration's `name` parameter, and described using the `description` parameter.
- In ascending order, tokenIds are appended to the `name` resulting in NFT metadata names such as NFT #0001.
- tokenIds are padded to the largest amount generated. IE, generating 999 objects will result in names NFT #001, using the above configuration, and generating 1000 objects will result in NFT #0001.
- As of `v1.0.2`, padding filenames has been removed.

Expand All @@ -80,4 +78,3 @@ As of `v1.0.2`, the IPFS CID may be updated programatically after generating NFT

### Credits
This project is completely coded by [Jonathan Becker](https://jbecker.dev), using no external libraries.

File renamed without changes.
153 changes: 0 additions & 153 deletions generate.py

This file was deleted.

10 changes: 0 additions & 10 deletions lib/util/io.py

This file was deleted.

Loading