Skip to content

Commit

Permalink
feat: initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Aug 18, 2024
1 parent 1097789 commit 3898279
Show file tree
Hide file tree
Showing 9 changed files with 846 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[flake8]
filename =
*.py
max-line-length = 120
extend-exclude =
venv/
130 changes: 130 additions & 0 deletions .github/workflows/update-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
---
name: Update

on:
pull_request:
branches: [master]
types: [opened, synchronize, reopened]
push:
branches: [master]
schedule:
- cron: '0 * * * *' # every hour
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements-dev.txt
- name: nbqa
run: |
python -m nbqa flake8 \
--color=always \
--verbose \
.
update_pages:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Checkout gh-pages
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
fetch-depth: 0 # otherwise, will fail to push refs to dest repo

- name: Setup python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 'latest'

- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
- name: Install npm dependencies
run: |
npm install
- name: Convert notebook
env:
GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN || secrets.GITHUB_TOKEN }}
run: |
jupyter nbconvert \
--debug \
--config=./jupyter_notebook_config.py \
--execute \
--no-input \
--to=html \
--output-dir=./gh-pages \
--output=index \
./notebook/dashboard.ipynb
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Prepare gh-pages
run: |
# empty contents
rm -f -r ./gh-pages/*
# copy dependencies
cp -f ./node_modules/plotly.js/dist/plotly.min.js ./gh-pages/plotly.js
- name: Archive gh-pages
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
shell: bash
run: |
7z \
"-xr!*.git*" \
a "./gh-pages.zip" "./gh-pages"
- name: Upload Artifacts
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
uses: actions/upload-artifact@v4
with:
name: gh-pages
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
path: |
${{ github.workspace }}/gh-pages.zip
- name: Deploy to gh-pages
if: >-
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch')
uses: actions-js/push@v1.5
with:
github_token: ${{ secrets.GH_BOT_TOKEN }}
author_email: ${{ secrets.GH_BOT_EMAIL }}
author_name: ${{ secrets.GH_BOT_NAME }}
directory: gh-pages
branch: gh-pages
force: false
message: automatic-update-${{ steps.date.outputs.date }}
170 changes: 170 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
# 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/
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/
cover/

# 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
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .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

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__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/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# generated html
gh-pages/
*.html

# node modules
node_modules/
package-lock.json
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# template-base
Base repository template for LizardByte.
# dashboard
A Jupyter notebook that creates a dashboard for viewing LizardByte repository data.

## Notes:
`ploty.js` must exist in the notebooks directory for the dashboard to be viewable by nbviewer.org.
It can be downloaded from their cdn: https://github.com/plotly/plotly.js/?tab=readme-ov-file#the-script-html-element

You can create a replica of the nbviewer.org dashboard by running the following command in the terminal:

```bash
jupyter nbconvert --to html notebook/dashboard.ipynb
```
2 changes: 2 additions & 0 deletions jupyter_nbconvert_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
c.Templateexporter.exclude_input_prompt = True
c.HTMLExporter.theme = 'dark'
Loading

0 comments on commit 3898279

Please sign in to comment.