diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..5e0f76e --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,50 @@ +name: Docs + +permissions: + contents: write + pages: write + +on: + push: + branches: [ "main", "master" ] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Activate conda env with environment.yml + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: environment.yml + cache-environment: true + post-cleanup: 'all' + + - name: Install nbdev + shell: bash -l {0} + run: | + pip install -U nbdev + + - name: Doing editable install + shell: bash -l {0} + run: | + test -f setup.py && pip install -e ".[dev]" + + - name: Run nbdev_docs + shell: bash -l {0} + run: | + nbdev_docs + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ github.token }} + force_orphan: true + publish_dir: ./_docs + # The following lines assign commit authorship to the official GH-Actions bot for deploys to `gh-pages` branch. + # You can swap them out with your own user credentials. + user_name: github-actions[bot] + user_email: 41898282+github-actions[bot]@users.noreply.github.com diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..d64403d --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,63 @@ +name: CI +on: [workflow_dispatch, pull_request, push] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Activate conda env with environment.yml + uses: mamba-org/setup-micromamba@v1 + with: + environment-file: environment.yml + cache-environment: true + post-cleanup: 'all' + + - name: Install nbdev + shell: bash -l {0} + run: | + pip install -U nbdev + + - name: Doing editable install + shell: bash -l {0} + run: | + test -f setup.py && pip install -e ".[dev]" + + - name: Check we are starting with clean git checkout + shell: bash -l {0} + run: | + if [[ `git status --porcelain -uno` ]]; then + git diff + echo "git status is not clean" + false + fi + + - name: Trying to strip out notebooks + shell: bash -l {0} + run: | + nbdev_clean + git status -s # display the status to see which nbs need cleaning up + if [[ `git status --porcelain -uno` ]]; then + git status -uno + echo -e "!!! Detected unstripped out notebooks\n!!!Remember to run nbdev_install_hooks" + echo -e "This error can also happen if you are using an older version of nbdev relative to what is in CI. Please try to upgrade nbdev with the command `pip install -U nbdev`" + false + fi + + - name: Run nbdev_export + shell: bash -l {0} + run: | + nbdev_export + if [[ `git status --porcelain -uno` ]]; then + echo "::error::Notebooks and library are not in sync. Please run nbdev_export." + git status -uno + git diff + exit 1; + fi + + - name: Run nbdev_test + shell: bash -l {0} + run: | + nbdev_test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f112e2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,151 @@ +_docs/ +_proc/ + +*.bak +.gitattributes +.last_checked +.gitconfig +*.bak +*.log +*~ +~* +_tmp* +tmp* +tags +*.pkg + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# 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/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# dotenv +.env + +# virtualenv +.venv +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + +.vscode +*.swp + +# osx generated files +.DS_Store +.DS_Store? +.Trashes +ehthumbs.db +Thumbs.db +.idea + +# pytest +.pytest_cache + +# tools/trust-doc-nbs +docs_src/.last_checked + +# symlinks to fastai +docs_src/fastai +tools/fastai + +# link checker +checklink/cookies.txt + +# .gitconfig is now autogenerated +.gitconfig + +# Quarto installer +.deb +.pkg + +# Quarto +.quarto diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..36774ed --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Vivek Gopalakrishnan + +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. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..5c0e7ce --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,5 @@ +include settings.ini +include LICENSE +include CONTRIBUTING.md +include README.md +recursive-exclude * __pycache__ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4da88e2 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +DiffPose +================ + + + +This file will become your README and also the index of your +documentation. + +## Install + +``` sh +pip install DiffPose +``` + +## How to use + +Fill me in please! Don’t forget code examples: + +``` python +1+1 +``` + + 2 diff --git a/diffpose/__init__.py b/diffpose/__init__.py new file mode 100644 index 0000000..f102a9c --- /dev/null +++ b/diffpose/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/diffpose/_modidx.py b/diffpose/_modidx.py new file mode 100644 index 0000000..9a18042 --- /dev/null +++ b/diffpose/_modidx.py @@ -0,0 +1,8 @@ +# Autogenerated by nbdev + +d = { 'settings': { 'branch': 'main', + 'doc_baseurl': '/DiffPose', + 'doc_host': 'https://vivekg.dev', + 'git_url': 'https://github.com/eigenvivek/DiffPose', + 'lib_path': 'diffpose'}, + 'syms': {}} diff --git a/notebooks/_quarto.yml b/notebooks/_quarto.yml new file mode 100644 index 0000000..0a6dfcb --- /dev/null +++ b/notebooks/_quarto.yml @@ -0,0 +1,20 @@ +project: + type: website + +format: + html: + theme: cosmo + css: styles.css + toc: true + +website: + twitter-card: true + open-graph: true + repo-actions: [issue] + navbar: + background: primary + search: true + sidebar: + style: floating + +metadata-files: [nbdev.yml, sidebar.yml] \ No newline at end of file diff --git a/notebooks/index.ipynb b/notebooks/index.ipynb new file mode 100644 index 0000000..b30d714 --- /dev/null +++ b/notebooks/index.ipynb @@ -0,0 +1,86 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# DiffPose\n", + "\n", + "> Patient-specific intraoperative 2D/3D registration via differentiable rendering" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This file will become your README and also the index of your documentation." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Install" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "```sh\n", + "pip install DiffPose\n", + "```" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## How to use" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Fill me in please! Don't forget code examples:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "1+1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "python3", + "language": "python", + "name": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/notebooks/nbdev.yml b/notebooks/nbdev.yml new file mode 100644 index 0000000..dc6c5f2 --- /dev/null +++ b/notebooks/nbdev.yml @@ -0,0 +1,9 @@ +project: + output-dir: _docs + +website: + title: "diffpose" + site-url: "https://vivekg.dev/DiffPose" + description: "Patient-specific intraoperative 2D/3D registration via differentiable rendering" + repo-branch: main + repo-url: "https://github.com/eigenvivek/DiffPose" diff --git a/notebooks/styles.css b/notebooks/styles.css new file mode 100644 index 0000000..66ccc49 --- /dev/null +++ b/notebooks/styles.css @@ -0,0 +1,37 @@ +.cell { + margin-bottom: 1rem; +} + +.cell > .sourceCode { + margin-bottom: 0; +} + +.cell-output > pre { + margin-bottom: 0; +} + +.cell-output > pre, .cell-output > .sourceCode > pre, .cell-output-stdout > pre { + margin-left: 0.8rem; + margin-top: 0; + background: none; + border-left: 2px solid lightsalmon; + border-top-left-radius: 0; + border-top-right-radius: 0; +} + +.cell-output > .sourceCode { + border: none; +} + +.cell-output > .sourceCode { + background: none; + margin-top: 0; +} + +div.description { + padding-left: 2px; + padding-top: 5px; + font-style: italic; + font-size: 135%; + opacity: 70%; +} diff --git a/settings.ini b/settings.ini new file mode 100644 index 0000000..e9b35ed --- /dev/null +++ b/settings.ini @@ -0,0 +1,44 @@ +[DEFAULT] +# All sections below are required unless otherwise specified. +# See https://github.com/fastai/nbdev/blob/master/settings.ini for examples. + +### Python library ### +repo = DiffPose +lib_name = diffpose +version = 0.0.1 +min_python = 3.7 +license = mit +black_formatting = True + +### nbdev ### +doc_path = _docs +lib_path = diffpose +nbs_path = notebooks +recursive = True +tst_flags = notest +put_version_in_init = True + +### Docs ### +branch = main +custom_sidebar = False +doc_host = https://vivekg.dev +doc_baseurl = /DiffPose +git_url = https://github.com/eigenvivek/DiffPose +title = diffpose +readme_nb = index.ipynb + +### PyPI ### +audience = Developers +author = Vivek Gopalakrihsnan +author_email = vivekg@mit.edu +copyright = 2023 onwards, Vivek Gopalakrishnan +description = Patient-specific intraoperative 2D/3D registration via differentiable rendering +keywords = nbdev jupyter notebook python +language = English +status = 3 +user = eigenvivek + +### Optional ### +# requirements = fastcore pandas +# dev_requirements = +# console_scripts = \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e3281ae --- /dev/null +++ b/setup.py @@ -0,0 +1,57 @@ +from pkg_resources import parse_version +from configparser import ConfigParser +import setuptools, shlex +assert parse_version(setuptools.__version__)>=parse_version('36.2') + +# note: all settings are in settings.ini; edit there, not here +config = ConfigParser(delimiters=['=']) +config.read('settings.ini', encoding='utf-8') +cfg = config['DEFAULT'] + +cfg_keys = 'version description keywords author author_email'.split() +expected = cfg_keys + "lib_name user branch license status min_python audience language".split() +for o in expected: assert o in cfg, "missing expected setting: {}".format(o) +setup_cfg = {o:cfg[o] for o in cfg_keys} + +licenses = { + 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'), + 'mit': ('MIT License', 'OSI Approved :: MIT License'), + 'gpl2': ('GNU General Public License v2', 'OSI Approved :: GNU General Public License v2 (GPLv2)'), + 'gpl3': ('GNU General Public License v3', 'OSI Approved :: GNU General Public License v3 (GPLv3)'), + 'bsd3': ('BSD License', 'OSI Approved :: BSD License'), +} +statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha', + '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ] +py_versions = '3.6 3.7 3.8 3.9 3.10'.split() + +requirements = shlex.split(cfg.get('requirements', '')) +if cfg.get('pip_requirements'): requirements += shlex.split(cfg.get('pip_requirements', '')) +min_python = cfg['min_python'] +lic = licenses.get(cfg['license'].lower(), (cfg['license'], None)) +dev_requirements = (cfg.get('dev_requirements') or '').split() + +setuptools.setup( + name = cfg['lib_name'], + license = lic[0], + classifiers = [ + 'Development Status :: ' + statuses[int(cfg['status'])], + 'Intended Audience :: ' + cfg['audience'].title(), + 'Natural Language :: ' + cfg['language'].title(), + ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]] + (['License :: ' + lic[1] ] if lic[1] else []), + url = cfg['git_url'], + packages = setuptools.find_packages(), + include_package_data = True, + install_requires = requirements, + extras_require={ 'dev': dev_requirements }, + dependency_links = cfg.get('dep_links','').split(), + python_requires = '>=' + cfg['min_python'], + long_description = open('README.md', encoding='utf-8').read(), + long_description_content_type = 'text/markdown', + zip_safe = False, + entry_points = { + 'console_scripts': cfg.get('console_scripts','').split(), + 'nbdev': [f'{cfg.get("lib_path")}={cfg.get("lib_path")}._modidx:d'] + }, + **setup_cfg) + +