Giter VIP home page Giter VIP logo

research-template's Introduction

opinionated Cookiecutter python research template

This is an opinionated template that I use for python research projects. It uses cookiecutter to dynamically create the project. Take a look at the cookiecutter.jsonfile to see what is configurable. Have a look at the resulting project structure in this repo.

The template is inspired by personal experience and preferences, the implementation in cookiecutter is inspired by python package template, (but is a little less 'fullblown' as it is aimed at (shorter-lived) research projects instead of more generic software projects).

It will perform/configure the following:

  • create a python package to wrap your code, making issues with python paths a thing of the past.
  • configure pytest for testing
  • configure pre-commit to conveniently bundle black, flake8, isort and some other formatting tools
  • (optionally) configure mypy for type checking. This is highly recommended, as in my experience you usually end up with specifying some type information in the docstrings anyway. Might as well make it more formal.
  • (optionally) configure darglint to validate docstrings (as I have a tendency to not update docstrings when refactoring)
  • github actions to test all of the above on each PR or commit to the master branch.
  • add a simple MIT license

Using the template

through github templates

you can use this github template to create a repository and then run the cookiecutter.

  1. create a new project in github and select 'from template'
  2. clone the repository
  3. run pip install cookiecutter
  4. run cookiecutter . to create the project
  5. remove all other files in the repo folder except for the newly created project.
  6. extract all content from the project root folder into the repo root folder, and remove the empty project root folder.

using cookiecutter

Here you have to create the git repository manually and push the project to git after you ran the cookiecutter.

  1. run pip install cookiecutter
  2. run cookiecutter https://github.com/tlpss/research-template.git. you will be prompted to configure the project.
  3. run cd <project>
  4. create a new blank repo on github
  5. follow the instructions to connect your project to the git repo and push the initial content

Additional steps

The project will wrap the python package in another directory, so that you could have multiple packages in the same repo (each with their own setup.py file), or add other files/code. Feel free te remove this additional layer but moving the content of the package directory to the top level and subsequently removing the directory.

More about creating python projects

There is no 'ultimate' setup here. It heavily depends on the scope and type of the project, the experience of your collaborators and yourself and ultimately personal preferences. E.g. I don't use poetry but conda as dependency manager, as this is more common in the research community. I also don't configure advanced testing tools like coverage etc, as these are typically not worth the time for smaller codebases imo. Same goes for documentation, no tools for documentation such as Sphinx or mkdocs are included, as most research projects don't need them. A good readme typically suffices.

Some pointers to learn more about setting up python (research) projects: Good research code handbook, python package template, Radix.ai resource page.

research-template's People

Contributors

adverley avatar tlpss avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

research-template's Issues

`provision-with-micromamba` github action fails after editing `environment.yaml`

This is not really a big issue with the template itself but can be fixed easily. I created a repo from this template and with the default environment.yaml the conda env creation CI worked. However with some small edits it suddenly failed.

I noticed that provision-with-micromamba has been deprecated:

Run mamba-org/provision-with-micromamba@main
Warning: This action is deprecated and no longer maintained. Please use mamba-org/setup-micromamba instead. See `[https://github.com/mamba-org/provision-with-micromamba#migration-to-setup-micromamba`](https://github.com/mamba-org/provision-with-micromamba#migration-to-setup-micromamba%60) for a migration guide.

So I migrated to setup-micromamba, after which my environment created succeeded again (see commit).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.