Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Publish fidesops to PyPI #491

Merged
merged 11 commits into from
May 16, 2022
Merged

Publish fidesops to PyPI #491

merged 11 commits into from
May 16, 2022

Conversation

PSalant726
Copy link
Contributor

@PSalant726 PSalant726 commented May 10, 2022

Purpose

Fidesops is not currently published to PyPI. This makes it difficult to install and use fidesops as a package in other Python projects. As work proceeds on https://github.com/ethyca/fidesops-plus, installing fidesops via git becomes cumbersome, as the enterprise team would like to maintain feature parity by pinning the imported version of fidesops.

Changes

  • Add missing __init__.py files (12 total)
    • And fix all ensuing static analysis errors
  • Add a GitHub Actions workflow to publish fidesops to PyPI whenever a new tag is created (releases)
    • The PYPI_TOKEN secret needs to be configured on this repository
  • Alphabetize requirements.txt
  • Add the versioneer dependency
  • Install versioneer
    • And use it in setup.py

Checklist

  • Applicable documentation updated (guides, quickstart, postman collections, tutorial, fidesdemo, database diagram.
  • If docs updated (select one):
    • documentation complete, or draft/outline provided (tag docs-team to complete/review on this branch)
    • documentation issue created (tag docs-team to complete issue separately)
  • Good unit test/integration test coverage
  • This PR contains a DB migration. If checked, the reviewer should confirm with the author that the down_revision correctly references the previous migration before merging
  • The Run Unsafe PR Checks label has been applied, and checks have passed, if this PR touches any external services

Ticket

Fixes #481

@PSalant726 PSalant726 added enhancement New feature or request dev experience Enhancements to the overall DX high-risk This issue suggests changes that have a high-probability of breaking existing code run unsafe ci checks Triggers running of unsafe CI checks dependencies Pull requests that update a dependency file labels May 10, 2022
@PSalant726 PSalant726 self-assigned this May 10, 2022
Copy link
Contributor Author

@PSalant726 PSalant726 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The large number of added files is due mostly to the new __init__.py files that were previously missing, and the files added by versioneer.

Comment on lines 3 to 6
on:
push:
tags:
- "*"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There may be a better trigger for this workflow based on the preferred release process.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. @seanpreston does this now align with the current release process?

.github/workflows/publish_to_pypi.yml Show resolved Hide resolved
requirements.txt Show resolved Hide resolved
@PSalant726 PSalant726 removed the run unsafe ci checks Triggers running of unsafe CI checks label May 10, 2022
@PSalant726 PSalant726 force-pushed the publish-to-pypi branch 2 times, most recently from 8e1740e to 24264d4 Compare May 11, 2022 00:12
@PSalant726 PSalant726 marked this pull request as draft May 11, 2022 00:57
To automate version numbers
These errors are being surfaced due to the new `__init__.py` files.
@PSalant726 PSalant726 marked this pull request as ready for review May 11, 2022 03:15
@PSalant726 PSalant726 added the run unsafe ci checks Triggers running of unsafe CI checks label May 11, 2022
@ThomasLaPiana
Copy link
Contributor

I highly highly strongly recommend adopting the fidesctl docker setup so that in the production image the package is installed as if it was coming directly from pypi, it will catch so many potential packaging errors (such as no init files)

@ThomasLaPiana
Copy link
Contributor

in fidesctl we use multi-stage builds for our dockerfile. This means that when we run our tests we use a production image with fidesctl installed from a clean build, instead of symlinked. This makes sure that our tests run against a package that has been installed as if it were a pip install fidesctl.

This is definitely for another issue, but is a best practice that should be done in a follow-up to this one

@seanpreston
Copy link
Contributor

Hey @PSalant726 — thanks for being thorough, I worry that this PR is a little bloated as you seem to have changed a lot more than is required just to publish the project to PyPi?

@PSalant726
Copy link
Contributor Author

@ThomasLaPiana

I highly highly strongly recommend adopting the fidesctl docker setup so that in the production image the package is installed as if it was coming directly from pypi, it will catch so many potential packaging errors (such as no init files)

in fidesctl we use multi-stage builds for our dockerfile. This means that when we run our tests we use a production image with fidesctl installed from a clean build, instead of symlinked. This makes sure that our tests run against a package that has been installed as if it were a pip install fidesctl.

I can create another issue to address this.


@seanpreston

I worry that this PR is a little bloated as you seem to have changed a lot more than is required just to publish the project to PyPi?

the linter error fixes were required to get the tests passing once the new __init__.py files existed. The __init__.py files are necessary to publish the complete package to PyPI. If you prefer, I can:

  1. Remove the new __init__.py files and associated fixes from this PR
  2. Create a new PR that adds the __init__.py files and fixes the linter errors
  3. Rebase this PR off of the new PR, such that this PR only 1) adds versioneer and 2) publishes to PyPI

Let me know if you prefer I do that.

@PSalant726 PSalant726 requested review from seanpreston and removed request for ThomasLaPiana May 12, 2022 17:22
@seanpreston seanpreston added run unsafe ci checks Triggers running of unsafe CI checks and removed run unsafe ci checks Triggers running of unsafe CI checks labels May 16, 2022
@@ -39,7 +46,7 @@ def get_strategy(
Returns the strategy given the name and configuration.
Raises NoSuchStrategyException if the strategy does not exist
"""
if strategy_name not in SupportedPaginationStrategies.__members__:
if not SupportedPaginationStrategies.__contains__(strategy_name):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the rationale for moving away from x in y?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous pattern was throwing a linter error because .__members__ is not a literal property of Enums (they don't implicitly inherit from dict, nor should they). Inclusion checks in Enums need to be implemented as custom functions.

errors = do_setup()
errors += scan_setup_py()
if errors:
sys.exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Versioneer need to be included like this vs. being a pip import itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

versioneer was added as an import:

versioneer==0.19

This script is the result of installing it with versioneer install. See https://github.com/python-versioneer/python-versioneer#theory-of-operation for more info.

@PSalant726 PSalant726 requested a review from seanpreston May 16, 2022 20:56
Copy link
Contributor

@seanpreston seanpreston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @PSalant726

@seanpreston seanpreston merged commit 6bf5af0 into main May 16, 2022
@seanpreston seanpreston deleted the publish-to-pypi branch May 16, 2022 21:09
adamsachs pushed a commit to adamsachs/fidesops_forked_test that referenced this pull request May 17, 2022
* Add missing `__init__.py` files

* Publish to PyPI on new tag creation

* Alphabetize `requirements.txt`

There are no version number or constraint changes - only ordering.

* Add `versioneer`

To automate version numbers

* Fix a metric ton of linter errors

These errors are being surfaced due to the new `__init__.py` files.

* Publish to PyPI on published releases

* Test that the `request_id` param actually filters

* Update references to the `id` query param to `request_id`

* Test publishes to PyPI

* Publish to testpypi prior to production
sanders41 pushed a commit that referenced this pull request Sep 22, 2022
* Add missing `__init__.py` files

* Publish to PyPI on new tag creation

* Alphabetize `requirements.txt`

There are no version number or constraint changes - only ordering.

* Add `versioneer`

To automate version numbers

* Fix a metric ton of linter errors

These errors are being surfaced due to the new `__init__.py` files.

* Publish to PyPI on published releases

* Test that the `request_id` param actually filters

* Update references to the `id` query param to `request_id`

* Test publishes to PyPI

* Publish to testpypi prior to production
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dependencies Pull requests that update a dependency file dev experience Enhancements to the overall DX enhancement New feature or request high-risk This issue suggests changes that have a high-probability of breaking existing code run unsafe ci checks Triggers running of unsafe CI checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Publish fidesops to PyPI
3 participants