Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move build config to pyproject.toml #1015

Draft
wants to merge 1 commit into
base: major-release-4
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v2-dependencies-python3.10-{{ checksum "./docs/requirements.txt" }}
- v2-dependencies-python3.10-{{ checksum "pyproject.toml" }}
# fallback to using the latest cache if no exact match is found
- v2-dependencies-python3.10-
- run:
Expand All @@ -36,11 +36,11 @@ jobs:
command: |
python3 -m venv venv
. venv/bin/activate
pip install -r ./docs/requirements.txt
pip install .[all,docs]
- save_cache:
paths:
- ./venv
key: v2-dependencies-python3.10-{{ checksum "./docs/requirements.txt" }}
key: v2-dependencies-python3.10-{{ checksum "pyproject.toml" }}
- run:
name: Build docs
command: |
Expand All @@ -57,7 +57,7 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v2-dependencies-python3.10-{{ checksum "./docs/requirements.txt" }}
- v2-dependencies-python3.10-{{ checksum "pyproject.toml" }}
# fallback to using the latest cache if no exact match is found
- v2-dependencies-python3.10-
- run:
Expand All @@ -69,11 +69,11 @@ jobs:
npm install -g --silent [email protected]
python3 -m venv venv
. venv/bin/activate
pip install -r ./docs/requirements.txt
pip install .[all,docs]
- save_cache:
paths:
- ./venv
key: v2-dependencies-python3.10-{{ checksum "./docs/requirements.txt" }}
key: v2-dependencies-python3.10-{{ checksum "pyproject.toml" }}
- add_ssh_keys:
# This SSH key is "CircleCI Docs" in https://github.com/move-coop/parsons/settings/keys
# We need write access to the Parsons repo, so we can push the "gh-pages" branch.
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/test-linux-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ jobs:
PARSONS_LIMITED_DEPENDENCIES: ${{ matrix.limited-dependencies }}
run: |
python -m pip install -U pip
python -m pip install .[all]
python -m pip install -r requirements-dev.txt
python -m pip install .[all,dev]

- name: Run tests
run: pytest -rf test/
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/tests-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ jobs:
cache: "pip"

- name: Install dependencies
env:
PARSONS_LIMITED_DEPENDENCIES: ${{ matrix.limited-dependencies }}
run: |
python -m pip install -U pip
python -m pip install .[all]
python -m pip install -r requirements-dev.txt
python -m pip install .[all,dev]

- name: Run tests
run: TESTING=1 pytest -rf test/

- name: check linting
- name: Check linting
run: |
# E203 and W503 don't work well with black
flake8 parsons/ test/ useful_resources/ --extend-ignore=E203,W503
Expand Down
101 changes: 73 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ We're thrilled that you're thinking about contributing to Parsons! Welcome to ou

You can find a detailed version of this guide [on our website](https://www.parsonsproject.org/pub/contributing-guide/).

The best way to get involved is by joining our Slack. To join, email [email protected]. In addition to all the great discussions that happen on our Slack, we also have virtual events including trainings, pairing sessions, social hangouts, discussions, and more. Every other Thursday afternoon we host 🎉 Parsons Parties 🎉 on Zoom where we work on contributions together.
The best way to get involved is by joining our Slack. To join, email [email protected]. In addition to
all the great discussions that happen on our Slack, we also have virtual events including trainings, pairing sessions,
social hangouts, discussions, and more. Every other Thursday afternoon we host 🎉 Parsons Parties 🎉 on Zoom where we work
on contributions together.

You can contribute by:

Expand All @@ -19,21 +22,31 @@ We encourage folks to review existing issues before starting a new issue.
* If you have code snippets, but don’t have time to do the full write, please add to the issue!

We use labels to help us classify issues. They include:

* **bug** - something in Parsons isn’t working the way it should
* **enhancement** - new feature or request (e.g. a new API connector)
* **good first issue** - an issue that would be good for someone who is new to Parsons

## Contributing Code to Parsons

Generally, code contributions to Parsons will be either enhancements or bug requests (or contributions of [sample code](#sample-code), discussed below). All changes to the repository are made [via pull requests](#submitting-a-pull-request).
Generally, code contributions to Parsons will be either enhancements or bug requests (or contributions
of [sample code](#sample-code), discussed below). All changes to the repository are
made [via pull requests](#submitting-a-pull-request).

If you would like to contribute code to Parsons, please review the issues in the repository and find one you would like to work on. If you are new to Parsons or to open source projects, look for issues with the [**good first issue**](https://github.com/move-coop/parsons/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label. Once you have found your issue, please add a comment to the issue that lets others know that you are interested in working on it. If you're having trouble finding something to work on, please ask us for help on Slack.
If you would like to contribute code to Parsons, please review the issues in the repository and find one you would like
to work on. If you are new to Parsons or to open source projects, look for issues with the [**good first issue
**](https://github.com/move-coop/parsons/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label. Once you
have found your issue, please add a comment to the issue that lets others know that you are interested in working on it.
If you're having trouble finding something to work on, please ask us for help on Slack.

The bulk of Parsons is made up of Connector classes, which are Python classes that help move data in and out of third party services. When you feel ready, you may want to contribute by [adding a new Connector class](https://move-coop.github.io/parsons/html/build_a_connector.html).
The bulk of Parsons is made up of Connector classes, which are Python classes that help move data in and out of third
party services. When you feel ready, you may want to contribute
by [adding a new Connector class](https://move-coop.github.io/parsons/html/build_a_connector.html).

### Making Changes to Parsons

To make code changes to Parsons, you'll need to set up your development environment, make your changes, and then submit a pull request.
To make code changes to Parsons, you'll need to set up your development environment, make your changes, and then submit
a pull request.

To set up your development environment:

Expand All @@ -43,13 +56,18 @@ To set up your development environment:
* Install the [dependencies](#installing-dependencies)
* Check that everything's working by [running the unit tests](#unit-tests) and the [linter](#linting)

Now it's time to make your changes. We suggest taking a quick look at our [coding conventions](#coding-conventions) - it'll make the review process easier down the line. In addition to any code changes, make sure to update the documentation and the unit tests if necessary. Not sure if your changes require test or documentation updates? Just ask in Slack or through a comment on the relevant issue. When you're done, make sure to run the [unit tests](#unit-tests) and the [linter](#linting) again.
Now it's time to make your changes. We suggest taking a quick look at our [coding conventions](#coding-conventions) -
it'll make the review process easier down the line. In addition to any code changes, make sure to update the
documentation and the unit tests if necessary. Not sure if your changes require test or documentation updates? Just ask
in Slack or through a comment on the relevant issue. When you're done, make sure to run the [unit tests](#unit-tests)
and the [linter](#linting) again.

Finally, you'll want to [submit a pull request](#submitting-a-pull-request). And that's it!

#### Virtual Environments

If required dependencies conflict with packages or modules you need for other projects, you can create and use a [virtual environment](https://docs.python.org/3/library/venv.html).
If required dependencies conflict with packages or modules you need for other projects, you can create and use
a [virtual environment](https://docs.python.org/3/library/venv.html).

```
python3 -m venv .venv # Creates a virtual environment in the .venv folder
Expand All @@ -59,35 +77,42 @@ source .venv/bin/activate # Activate in Unix or MacOS

#### Installing Dependencies

Before running or testing your code changes, be sure to install all of the required Python libraries that Parsons depends on.
Before running or testing your code changes, be sure to install all of the required Python libraries that Parsons
depends on.

From the root of the parsons repository, use the run the following command:

```bash
> pip install -r requirements.txt
> pip install .[all,dev]
```

#### Unit Tests

When contributing code, we ask you to add to tests that can be used to verify that the code is working as expected. All of our unit tests are located in the `test/` folder at the root of the repository.
When contributing code, we ask you to add to tests that can be used to verify that the code is working as expected. All
of our unit tests are located in the `test/` folder at the root of the repository.

We use the pytest tool to run our suite of automated unit tests. The pytest command line tool is installed as part of the Parsons dependencies.
We use the pytest tool to run our suite of automated unit tests. The pytest command line tool is installed as part of
the Parsons dependencies.

To run all the entire suite of unit tests, execute the following command:

```bash
> pytest -rf test/
```

Once the pytest tool has finished running all of the tests, it will output details around any errors or test failures it encountered. If no failures are identified, then you are good to go!
Once the pytest tool has finished running all of the tests, it will output details around any errors or test failures it
encountered. If no failures are identified, then you are good to go!

**Note:*** Some tests are written to call out to external API’s, and will be skipped as part of standard unit testing. This is expected.
**Note:*** Some tests are written to call out to external API’s, and will be skipped as part of standard unit testing.
This is expected.

See the [pytest documentation](https://docs.pytest.org/en/latest/contents.html) for more info and many more options.

#### Linting

We use the [black](https://github.com/psf/black) and [flake8](http://flake8.pycqa.org/en/latest/) tools to [lint](https://en.wikipedia.org/wiki/Lint_(software)) the code in the repository to make sure it matches our preferred style. Both tools are installed as part of the Parsons dependencies.
We use the [black](https://github.com/psf/black) and [flake8](http://flake8.pycqa.org/en/latest/) tools
to [lint](https://en.wikipedia.org/wiki/Lint_(software)) the code in the repository to make sure it matches our
preferred style. Both tools are installed as part of the Parsons dependencies.

Run the following commands from the root of the Parsons repository to lint your code changes:

Expand All @@ -107,48 +132,64 @@ pre-commit`, and then run `pre-commit install`.

The following is a list of best practices to consider when writing code for the Parsons project:

* Each tool connector should be its own unique class (e.g. ActionKit, VAN) in its own Python package. Use existing connectors as examples when deciding how to layout your code.
* Each tool connector should be its own unique class (e.g. ActionKit, VAN) in its own Python package. Use existing
connectors as examples when deciding how to layout your code.

* Methods should be named using a verb_noun structure, such as `get_activist()` or `update_event()`.

* Methods should reflect the vocabulary utilized by the original tool where possible to mantain transparency. For example, Google Cloud Storage refers to file like objects as blobs. The methods are called `get_blob()` rather than `get_file()`.
* Methods should reflect the vocabulary utilized by the original tool where possible to mantain transparency. For
example, Google Cloud Storage refers to file like objects as blobs. The methods are called `get_blob()` rather
than `get_file()`.

* Methods that can work with arbitrarily large data (e.g. database or API queries) should use of Parson Tables to hold the data instead of standard Python collections (e.g. lists, dicts).
* Methods that can work with arbitrarily large data (e.g. database or API queries) should use of Parson Tables to hold
the data instead of standard Python collections (e.g. lists, dicts).

* You should avoid abbreviations for method names and variable names where possible.

* Inline comments explaining complex codes and methods are appreciated.

* Capitalize the word Parsons for consistency where possible, especially in documentation.

If you are building a new connector or extending an existing connector, there are more best practices in the [How to Build a Connector](https://move-coop.github.io/parsons/html/build_a_connector.html) documentation.
If you are building a new connector or extending an existing connector, there are more best practices in
the [How to Build a Connector](https://move-coop.github.io/parsons/html/build_a_connector.html) documentation.

## Documentation

Parsons documentation is built using the Python Sphinx tool. Sphinx uses the `docs/*.rst` files in the repository to create the documentation.
Parsons documentation is built using the Python Sphinx tool. Sphinx uses the `docs/*.rst` files in the repository to
create the documentation.

We have a [documentation label](https://github.com/move-coop/parsons/issues?q=is%3Aissue+is%3Aopen+label%3Adocumentation) that may help you find good docs issues to work on. If you are adding a new connector, you will need to add a reference to the connector to one of the .rst files. Please use the existing documentation as an example.
We have
a [documentation label](https://github.com/move-coop/parsons/issues?q=is%3Aissue+is%3Aopen+label%3Adocumentation) that
may help you find good docs issues to work on. If you are adding a new connector, you will need to add a reference to
the connector to one of the .rst files. Please use the existing documentation as an example.

When editing documentation, make sure you are editing the source files (with .md or .rst extension) and not the build files (.html extension).
When editing documentation, make sure you are editing the source files (with .md or .rst extension) and not the build
files (.html extension).

The workflow for documentation changes is a bit simpler than for code changes:

* Fork the Parsons project using [the “Fork” button in GitHub](https://guides.github.com/activities/forking/)
* Clone your fork to your local computer
* Change into the `docs` folder and install the requirements with `pip install -r requirements.txt` (you may want to set up a [virtual environment](#virtual-environments) first)
* Make your changes and re-build the docs by running `make html`. (Note: this builds only a single version of the docs, from the current files. To create docs with multiple versions like our publicly hosted docs, run `make deploy_docs`.)
* Install the requirements with `pip install .[all,docs]` (you may want to set
up a [virtual environment](#virtual-environments) first)
* Change into the `docs` folder
* Make your changes and re-build the docs by running `make html`. (Note: this builds only a single version of the docs,
from the current files. To create docs with multiple versions like our publicly hosted docs, run `make deploy_docs`.)
* Open these files in your web browser to check that they look as you expect.
* [Submit a pull request](#submitting-a-pull-request)

When you make documentation changes, you only need to track the source files with git. The docs built by the html folder should not be included.
When you make documentation changes, you only need to track the source files with git. The docs built by the html folder
should not be included.

You should not need to worry about the unit tests or the linter if you are making documentation changes only.

## Contributing Sample Code

One important way to contribute to the Parsons project is to submit sample code that provides recipes and patterns for how to use the Parsons library.
One important way to contribute to the Parsons project is to submit sample code that provides recipes and patterns for
how to use the Parsons library.

We have a folder called `useful_resources/` in the root of the repository. If you have scripts that incorporate Parsons, we encourage you to add them there!
We have a folder called `useful_resources/` in the root of the repository. If you have scripts that incorporate Parsons,
we encourage you to add them there!

The workflow for adding sample code is:

Expand All @@ -161,8 +202,12 @@ You should not need to worry about the unit tests or the linter if you are only

## Submitting a Pull Request

To submit a pull request, follow [these instructions to create a Pull Request from your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork) back to the original Parsons repository.
To submit a pull request,
follow [these instructions to create a Pull Request from your fork](https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request-from-a-fork)
back to the original Parsons repository.

The Parsons team will review your pull request and provide feedback. Please feel free to ping us if no one's responded to your Pull Request after a few days. We may not be able to review it right away, but we should be able to tell you when we'll get to it.
The Parsons team will review your pull request and provide feedback. Please feel free to ping us if no one's responded
to your Pull Request after a few days. We may not be able to review it right away, but we should be able to tell you
when we'll get to it.

Once your pull request has been approved, the Parsons team will merge your changes into the Parsons repository
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@ ENV DISPLAY=:99

RUN mkdir /src

COPY requirements.txt /src/
RUN pip install -r /src/requirements.txt

COPY . /src/
WORKDIR /src

RUN python setup.py develop
RUN pip install -U pip build
RUN python -m build
RUN pip install .[all,tmc]

# The /app directory can house the scripts that will actually execute on this Docker image.
# Eg. If using this image in a Civis container script, Civis will install your script repo
# (from Github) to /app.
RUN mkdir /app
WORKDIR /app
# Useful for importing modules that are associated with your python scripts:
ENV PYTHONPATH=.:/app
ENV PYTHONPATH=.:/app
Loading