Skip to content

Commit

Permalink
Project structure from Tianshou
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocagnetta committed Feb 26, 2024
1 parent 3b6d1a1 commit fefbe9f
Show file tree
Hide file tree
Showing 68 changed files with 1,207 additions and 1,609 deletions.
33 changes: 0 additions & 33 deletions .gitlab-ci.yml

This file was deleted.

16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,16 @@ for gitlab, for github you should configure the pages source to be the root dire

In the documentation links to source code will be created, therefore you will be prompted to give the project's url.

See the resulting repository's [developer's readme]({{cookiecutter.project_name}}/README-dev.md) for further details. An example of the current output of this template is in [pymetrius_output](https://github.com/appliedAI-Initiative/pymetrius_output)
See the resulting repository's [developer's readme]({{cookiecutter.project_name}}/CONTRIBUTING.md) for further details. An example of the current output of this template is in [pymetrius_output](https://github.com/appliedAI-Initiative/pymetrius_output)

# Usage

## Prerequisites

The template supports python 3.8 and higher. For a smooth project generation you need to have
The template supports python 3.11 and higher. For a smooth project generation you need to have

1) Python of the correct version installed on your system.
2) The venv module for that python version. If not installed yet, you can install it with
```shell script
sudo apt-get update && apt-get install python<VERSION>-venv
```
3) Cookiecutter. Install it e.g. with `pip install cookiecutter`
2) Cookiecutter. Install it e.g. with `pip install cookiecutter`


## Creating a new project
Expand All @@ -44,9 +40,9 @@ cookiecutter https://github.com/appliedAI-Initiative/python_library_template -o
and walk through the questions. You can also clone this repository, adjust the template and call cookiecutter on
the local file.

You will get a repo in `<path/to/directory>/<project_name>` with a venv inside it; the venv will contain your new
library installed in "editable mode" (i.e. with `pip install -e` ).
If you prefer to use a different virtual environment (like conda), feel free to delete the venv.
You will get a repo in `<path/to/directory>/<project_name>`, which will contain your new library installed in
"editable mode" (i.e. with `pip install -e` ). The virtual environment is created by poetry. Documentation is built with
jupyter-book and is published on github pages.


# Contributing
Expand Down
9 changes: 5 additions & 4 deletions cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"project_name": null,
"author": null,
"project_name": "test",
"author": "carlo",
"author_email": "[email protected]",
"package_name": "{{cookiecutter.project_name}}",
"python_version": ["3.8", "3.9"],
"python_version": ["3.11", "3.12"],
"project_url": "https://github.com/{{cookiecutter.author}}/{{cookiecutter.project_name}}",
"include_configuration_utils": ["Y", "n"],
"include_accsr_configuration_utils": ["N", "y"],
"include_readthedocs_yaml": ["N", "y"],
"initial_version": "0.1.0",
"_copy_without_render": [
Expand Down
42 changes: 6 additions & 36 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,18 @@ def delete_line_in_file(filepath: str, line_starts_with: str):
if "{{cookiecutter.include_readthedocs_yaml}}".lower() != "y":
remove(".readthedocs.yaml")

if "{{cookiecutter.include_configuration_utils}}".lower() != "y":
if "{{cookiecutter.include_accsr_configuration_utils}}".lower() != "y":
remove("config.py")
remove("config.json")
remove("notebooks/config_example.ipynb")
delete_line_in_file("requirements-dev.txt", "accsr")
delete_line_in_file("requirements-test.txt", "accsr")
remove("docs/02_notebooks/config_example.ipynb")
remove("data")
delete_line_in_file("pyproject.toml", "accsr")
delete_line_in_file(".gitignore", "config_local.json")

return_code = os.system(
"""
echo "Initializing your new project in $(pwd). This might take a while"
# THIS IS A NAIVE HACK TO PREVENT COOKIECUTTER FROM RENDERING IN GITHUB WORKFLOWS
cat .github/workflows/tox-addition.yaml >> .github/workflows/tox.yaml
rm .github/workflows/tox-addition.yaml
return_code = os.system("""
echo "Initializing your new project in $(pwd)."
git init
echo "Creating and activating venv"
python{{cookiecutter.python_version}} -m venv ./.venv
. .venv/bin/activate
echo "Installing dev requirements"
pip install -q -r requirements-dev.txt
echo "Performing Initial formatting"
black . && isort . && nbstripout notebooks/*
echo "Setting git hooks"
pre-commit install
pre-commit autoupdate
echo "Initial commit"
git checkout -b develop
git add . && git add -f data/raw/hello.txt
git commit -q -m "Initial commit by pymetrius"
echo "Installing {{cookiecutter.project_name}} in editable mode into .venv"
pip install -q -e .
echo "A virtual environment for your project has been created in $(pwd)/.venv, \
the library was installed there in editable mode."
echo "Running the sample script"
python scripts/run_sample.py
echo "All done, you can start by running tox (will take a while the first time) and looking at the docu in \
docs/_build/html. \n \
You can also just quickly run tests and build the docu using \n \
./build_scripts/run-all-tests-with-coverage.sh \n
./build_scripts/build-docs.sh \n \"
"""
)
if return_code:
Expand Down
2 changes: 1 addition & 1 deletion tests/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
default_context:
project_name: pymetrius_output
author: automated_user
python_version: 3.8
python_version: 3.11
project_url: https://github.com/appliedAI-Initiative/pymetrius_output
22 changes: 0 additions & 22 deletions {{cookiecutter.project_name}}/.bumpversion.cfg

This file was deleted.

2 changes: 0 additions & 2 deletions {{cookiecutter.project_name}}/.coveragerc

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_REPO_PASS }}
{%- endraw %}
run: |
# TODO: build dist with poetry
python setup.py sdist bdist_wheel
twine upload dist/*
27 changes: 0 additions & 27 deletions {{cookiecutter.project_name}}/.github/workflows/tox-addition.yaml

This file was deleted.

42 changes: 0 additions & 42 deletions {{cookiecutter.project_name}}/.github/workflows/tox.yaml

This file was deleted.

139 changes: 0 additions & 139 deletions {{cookiecutter.project_name}}/.gitlab-ci.yml

This file was deleted.

Loading

0 comments on commit fefbe9f

Please sign in to comment.