Skip to content

Commit

Permalink
Merge pull request #1202 from consideRatio/pr/enable-pyupgrade
Browse files Browse the repository at this point in the history
pre-commit: add pyupgrade, isort, and prettier for .md files
  • Loading branch information
yuvipanda authored Nov 1, 2022
2 parents eab0b50 + ae3aeb6 commit b6098c0
Show file tree
Hide file tree
Showing 86 changed files with 535 additions and 628 deletions.
20 changes: 12 additions & 8 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
---
name: Bug report
about: Create a report to help us repair something that is currently broken
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

<!-- Thank you for contributing. These HTML commments will not render in the issue, but you can delete them once you've read them if you prefer! -->

### Bug description

<!-- Use this section to clearly and concisely describe the bug. -->

#### Expected behaviour

<!-- Tell us what you thought would happen. -->

#### Actual behaviour

<!-- Tell us what you actually happens. -->

### How to reproduce

<!-- Use this section to describe the steps that a user would take to experience this bug. -->

1. Go to '...'
Expand All @@ -26,9 +30,9 @@ assignees: ''
4. See error

### Your personal set up
<!-- Tell us a little about the system you're using. You can see the guidelines for setting up and reporting this information at https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html#setting-up-for-local-development. -->

- OS: [e.g. linux, OSX]
- Docker version: `docker version` <!-- Run this command to get your version. -->
- repo2docker version `repo2docker --version` <!-- Run this command to get your version. -->
<!-- Tell us a little about the system you're using. You can see the guidelines for setting up and reporting this information at https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html#setting-up-for-local-development. -->

- OS: [e.g. linux, OSX]
- Docker version: `docker version` <!-- Run this command to get your version. -->
- repo2docker version `repo2docker --version` <!-- Run this command to get your version. -->
18 changes: 9 additions & 9 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
---
name: Feature request
about: Suggest a new feature or a big change to repo2docker
title: ''
labels: 'needs: discussion'
assignees: ''

title: ""
labels: "needs: discussion"
assignees: ""
---

<!-- Thank you for contributing. These HTML commments will not render in the issue, but you can delete them once you've read them if you prefer! -->

### Proposed change
<!-- Use this section to describe the feature you'd like to be added. -->

<!-- Use this section to describe the feature you'd like to be added. -->

### Alternative options
<!-- Use this section to describe alternative options and why you've decided on the proposed feature above. -->

<!-- Use this section to describe alternative options and why you've decided on the proposed feature above. -->

### Who would use this feature?
<!-- Describe the audience for this feature. This information will affect who chooses to work on the feature with you. -->

<!-- Describe the audience for this feature. This information will affect who chooses to work on the feature with you. -->

### How much effort will adding it take?
<!-- Try to estimate how much work adding this feature will require. This information will affect who chooses to work on the feature with you. -->

<!-- Try to estimate how much work adding this feature will require. This information will affect who chooses to work on the feature with you. -->

### Who can do this work?
<!-- What skills are needed? Who can be recruited to add this feature? This information will affect who chooses to work on the feature with you. -->

<!-- What skills are needed? Who can be recruited to add this feature? This information will affect who chooses to work on the feature with you. -->
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/support-question.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Support question
about: Ask a question about using repo2docker
title: ''
labels: ''
assignees: ''

title: ""
labels: ""
assignees: ""
---

🚨 Please do **not** open an issue for support questions. Instead please search for similar issues or post on http://discourse.jupyter.org/c/questions. 🚨
Expand Down
44 changes: 25 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
# - Register git hooks: pre-commit install --install-hooks
#
repos:
# # Autoformat: Python code, syntax patterns are modernized
# - repo: https://github.com/asottile/pyupgrade
# rev: v3.0.0
# hooks:
# - id: pyupgrade
# args:
# - --py38-plus
# Autoformat: Python code, syntax patterns are modernized
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade
args:
- --py36-plus
# check-tmp is a Python based test script run in created environments
# that can be at least Python 3.5 even though we require Python 3.6 for
# repo2docker itself.
exclude: check-tmp

# Autoformat: Python code
- repo: https://github.com/psf/black
Expand All @@ -28,17 +32,19 @@ repos:
- --target-version=py38
- --target-version=py39
- --target-version=py310
- --target-version=py311

# # Autoformat: Python code
# - repo: https://github.com/pycqa/isort
# rev: 5.10.1
# hooks:
# - id: isort
# args:
# - --profile=black
# Autoformat: Python code
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
args:
- --profile=black

# # Autoformat: markdown, yaml (but not helm templates)
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v2.7.1
# hooks:
# - id: prettier
# Autoformat: markdown
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
files: ".md"
23 changes: 12 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ The repo2docker developer documentation is all rendered on our documentation web
If you're here, you're probably looking for the [Contributing to repo2docker development](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html) page.

Please make sure you've read the following sections before opening an issue/pull request:
* [Process for making a contribution](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html#process-for-making-a-contribution).
* These steps talk you through choosing the right issue template (bug report or feature request) and making a change.
* [Guidelines to getting a Pull Request merged](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html#guidelines-to-getting-a-pull-request-merged).
* These are tips and tricks to help make your contribution as smooth as possible for you and for the repo2docker maintenance team.

- [Process for making a contribution](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html#process-for-making-a-contribution).
- These steps talk you through choosing the right issue template (bug report or feature request) and making a change.
- [Guidelines to getting a Pull Request merged](https://repo2docker.readthedocs.io/en/latest/contributing/contributing.html#guidelines-to-getting-a-pull-request-merged).
- These are tips and tricks to help make your contribution as smooth as possible for you and for the repo2docker maintenance team.

There are a few other pages to highlight:

* [Our roadmap](https://repo2docker.readthedocs.io/en/latest/contributing/roadmap.html)
* We use the roadmap to develop a shared understanding of the project's vision and direction amongst the community of users, contributors, and maintainers.
- [Our roadmap](https://repo2docker.readthedocs.io/en/latest/contributing/roadmap.html)
- We use the roadmap to develop a shared understanding of the project's vision and direction amongst the community of users, contributors, and maintainers.
This is a great place to get a feel for what the maintainers are thinking about for the short, medium, and long term future of the project.
* [Design of repo2docker](https://repo2docker.readthedocs.io/en/latest/design.html)
* This page explains some of the design principles behind repo2docker.
- [Design of repo2docker](https://repo2docker.readthedocs.io/en/latest/design.html)
- This page explains some of the design principles behind repo2docker.
Its a good place to understand _why_ the team have made the decisions that they have along the way!
* We absolutely encourage discussion around refactoring, updating or extending repo2docker, but please make sure that you've understood this page before opening an issue to discuss the change you'd like to propose.
* [Common developer tasks and how-tos](https://repo2docker.readthedocs.io/en/latest/contributing/tasks.html)
* Some notes on running tests, buildpack dependencies, creating a release, and keeping the pip files up to date.
- We absolutely encourage discussion around refactoring, updating or extending repo2docker, but please make sure that you've understood this page before opening an issue to discuss the change you'd like to propose.
- [Common developer tasks and how-tos](https://repo2docker.readthedocs.io/en/latest/contributing/tasks.html)
- Some notes on running tests, buildpack dependencies, creating a release, and keeping the pip files up to date.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ For more information, please visit
---

## Using repo2docker

### Prerequisites

1. Docker to build & run the repositories. The [community edition](https://store.docker.com/search?type=edition&offering=community)
Expand Down Expand Up @@ -83,21 +84,19 @@ something like:
If you copy paste that URL into your browser you will see a Jupyter Notebook
with the contents of the repository you had just built!

For more information on how to use ``repo2docker``, see the
For more information on how to use `repo2docker`, see the
[usage guide](http://repo2docker.readthedocs.io/en/latest/usage.html).


## Repository specifications

Repo2Docker looks for configuration files in the source repository to
determine how the Docker image should be built. For a list of the configuration
files that ``repo2docker`` can use, see the
files that `repo2docker` can use, see the
[complete list of configuration files](https://repo2docker.readthedocs.io/en/latest/config_files.html).

The philosophy of repo2docker is inspired by
[Heroku Build Packs](https://devcenter.heroku.com/articles/buildpacks).


## Docker Image

Repo2Docker can be run inside a Docker container if access to the Docker Daemon is provided, for example see [BinderHub](https://github.com/jupyterhub/binderhub). Docker images are [published to quay.io](https://quay.io/repository/jupyterhub/repo2docker?tab=tags). The old [Docker Hub image](https://hub.docker.com/r/jupyter/repo2docker) is no longer supported.
14 changes: 7 additions & 7 deletions docs/source/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This is a living document talking about the architecture of repo2docker
from various perspectives.

(buildpacks)=

## Buildpacks

The **buildpack** concept comes from [Heroku](https://devcenter.heroku.com/articles/buildpacks)
Expand Down Expand Up @@ -57,19 +58,19 @@ and basic notebook packages (from `repo2docker/buildpacks/conda/environment.yml`
to be the same for most repositories built with `CondaBuildPack`, so we want to use
[docker layer caching](https://thenewstack.io/understanding-the-docker-cache-for-faster-builds/) as
much as possible for performance reasons. Next time a repository is built with `CondaBuildPack`,
we can skip straight to the **copy** step (since the base environment docker image *layers* have
we can skip straight to the **copy** step (since the base environment docker image _layers_ have
already been built and cached).

The `get_build_scripts` and `get_build_script_files` methods are primarily used for this.
`get_build_scripts` can return arbitrary bash script lines that can be run as different users,
and `get_build_script_files` is used to copy specific scripts (such as a conda installer) into
the image to be run as pat of `get_build_scripts`. Code in either has following constraints:

1. You can *not* use the contents of repository in them, since this happens before the repository
1. You can _not_ use the contents of repository in them, since this happens before the repository
is copied into the image. For example, `pip install -r requirements.txt` will not work,
since there's no `requirements.txt` inside the image at this point. This is an explicit
design decision, to enable better layer caching.
2. You *may*, however, read the contents of the repository and modify the scripts emitted based
2. You _may_, however, read the contents of the repository and modify the scripts emitted based
on that! For example, in `CondaBuildPack`, if there's Python 2 specified in `environment.yml`,
a different kind of environment is set up. The reading of the `environment.yml` is performed
in the BuildPack itself, and not in the scripts returned by `get_build_scripts`. This is fine.
Expand Down Expand Up @@ -118,20 +119,19 @@ a path to a repository. This might be a local path or a URL. Upon being called,
`repo2docker` will loop through all ContentProviders and perform the following
commands:

* Run the `detect()` method on the repository path given to `repo2docker`. This
- Run the `detect()` method on the repository path given to `repo2docker`. This
should return any value other than `None` if the path matches what the ContentProvider is looking
for.

> For example, the [`Local` ContentProvider](https://github.com/jupyterhub/repo2docker/blob/80b979f8580ddef184d2ba7d354e7a833cfa38a4/repo2docker/contentproviders/base.py#L64)
> checks whether the argument is a valid local path. If so, then `detect(`
> returns a dictionary: `{'path': source}` which defines the path to the repository.
> This path is used by `fetch()` to check that it matches the output directory.
* If `detect()` returns something other than `None`, run `fetch()` with the
- If `detect()` returns something other than `None`, run `fetch()` with the
returned value as its argument. This should
result in the contents of the repository being placed locally to a folder.

For more information on ContentProviders, take a look at
[the ContentProvider base class](https://github.com/jupyterhub/repo2docker/blob/80b979f8580ddef184d2ba7d354e7a833cfa38a4/repo2docker/contentproviders/base.py#L16-L60)
which has more explanation.


7 changes: 2 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
import datetime


# -- Project information -----------------------------------------------------
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
#
Expand Down Expand Up @@ -61,12 +60,10 @@

default_python = CondaBuildPack.major_pythons["3"]

rst_prolog = """
rst_prolog = f"""
.. |default_python| replace:: **Python {default_python}**
.. |default_python_version| replace:: {default_python}
""".format(
default_python=default_python
)
"""


# -- Options for HTML output -------------------------------------------------
Expand Down
Loading

0 comments on commit b6098c0

Please sign in to comment.