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

Port Django migrations inference away from PythonDependencyVisitorRequest #19008

Merged
merged 7 commits into from May 17, 2023

Conversation

thejcannon
Copy link
Member

This is the only in-repo plugin using PythonDependencyVisitorRequest, meaning when the rust parser is the new only implementation PythonDependencyVisitorRequest and plumbing can be removed (sooner if we refactor)

Implementation:

  • Switched to running a dedicated process for scraping, instead of piggybacking off of the existing one
  • Only scrape from files directly under a migrations directory

@thejcannon
Copy link
Member Author

(sooner if we refactor)

I might do this, just to start the cleanup 🤷‍♂️

Digest, CreateDigest([FileContent("apps.json", django_apps.to_json())])
) -> InferredDependencies:
source_field = request.field_set.source
# NB: This doesn't consider https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-MIGRATION_MODULES
Copy link
Member

Choose a reason for hiding this comment

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

This comment make me wonder if it wouldn't make sense to implement this as a hybrid Django-Pants plugin, to leverage the settings and Django-isms you get from a Django plugin, but run in the context of a Pants managed setting to avoid re-implementing/re-discovering how Django works under the covers.

Copy link
Member Author

Choose a reason for hiding this comment

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

So far we've avoided Pants-specific plugins to frameworks.

(That's my whole comment. Really this PR is just to support ripping out the old stuff)

Copy link
Member

Choose a reason for hiding this comment

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

Really this PR is just to support ripping out the old stuff

yea, just got me thinking..

So far we've avoided Pants-specific plugins to frameworks.

Actively avoided? (I've missed that memo 😅 ) ((if so, why? OK, I can come up with a few cons to doing it that way... but also a few pros))

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

I think it's fine to not worry about it. It's very rare to not call the migrations package migrations, and you always have the workaround of manual deps. If someone really needs this, they can add a Pants option to support that.

Copy link
Sponsor Contributor

@benjyw benjyw left a comment

Choose a reason for hiding this comment

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

🎉

Digest, CreateDigest([FileContent("apps.json", django_apps.to_json())])
) -> InferredDependencies:
source_field = request.field_set.source
# NB: This doesn't consider https://docs.djangoproject.com/en/4.2/ref/settings/#std-setting-MIGRATION_MODULES
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

I think it's fine to not worry about it. It's very rare to not call the migrations package migrations, and you always have the workaround of manual deps. If someone really needs this, they can add a Pants option to support that.

],
env_inherit={"PATH", "PYENV_ROOT", "HOME"},
)
def do_test_migration_dependencies(rule_runner: RuleRunner, constraints: str) -> None:
Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

For future reference, I would have preferred as few changes to the test as possible, as it is the insurance policy that the underlying code change is good, and so keeping it stable is strong reassurance that that test hasn't been cooked to match, so to speak.

Copy link
Member

Choose a reason for hiding this comment

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

+1. I did look at that and tried to see what the test changes where coming from.. but gave up ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, this round-tripped through some code that assumed that we'd do Py3 only

Copy link
Member Author

Choose a reason for hiding this comment

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

The core of the test has remained the exact same, however. The rest is the necessary tweaks and a little cleaning

@thejcannon thejcannon merged commit f9188ab into pantsbuild:main May 17, 2023
17 checks passed
@thejcannon thejcannon deleted the portdjango branch May 17, 2023 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants