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

Evaluate all defsetting arguments at runtime #38128

Merged
merged 3 commits into from
Feb 2, 2024

Conversation

crisptrutski
Copy link
Contributor

@crisptrutski crisptrutski commented Jan 25, 2024

Description

This refactor changes defsetting so that we only process its arguments at runtime, allowing us to use references and expressions to define things dynamically.

Note that this PR does not add support for a trailing kwargs map, that's left in #38090, which I plan to rebase on this branch. Scrapped that feature anyway.

@metabase-bot metabase-bot bot added the .Team/BackendComponents also known as BEC label Jan 25, 2024
@crisptrutski crisptrutski added the backport Automatically create PR on current release branch on merge label Jan 25, 2024
@crisptrutski crisptrutski requested a review from a team January 25, 2024 12:37
Copy link

replay-io bot commented Jan 25, 2024

StatusIn Progress ↗︎ 51 / 52
Commit9b8330e
Results
⚠️ 5 Flaky
2252 Passed

{:description-form ~description-form})))

;; This exists as its own method so that we can stub it in tests
(defn- in-test? [ns] (str/ends-with? ns "-test"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
(defn- in-test? [ns] (str/ends-with? ns "-test"))
(defn- ns-in-test? [ns] (str/ends-with? ns "-test"))

Copy link
Contributor

Choose a reason for hiding this comment

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

2 things:

  • I think we should prefix the name with ns, it was fine before if it does not take an argument
  • we should call ns-name on ns because I usually think when we see ns, we think of it as a symbol, not str. So we should avoid that footgun.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. It feels non-idiomatic to repeat the name of the arg in the fn name for a predicate, but don't feel strongly.
  2. The ns here is a symbol, which str/end-with? implicitly handles converting to a string. I think you meant you expect a clojure.lang.Namespace object? I want this method to "just work" with settings definitions, where we've already turned that into data (a symbol) by calling ns-name. I'll rename the argument itself to ns-name, which I think also removes my discomfort in (1) 😆

@crisptrutski crisptrutski force-pushed the evaluate-settings-options-at-runtime branch from bb72594 to 88f0c8d Compare January 26, 2024 08:38
{:description-form ~description-form})))

;; This exists as its own method so that we can stub it in tests
(defn- ns-in-test? [ns-name] (str/ends-with? ns-name "-test"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shower thought - instead of stubbing this we could cover its logic by switching namespaces within the test. Not sure which is the lesser evil 🙂

@crisptrutski crisptrutski force-pushed the evaluate-settings-options-at-runtime branch from 88f0c8d to c9c094f Compare January 26, 2024 15:57
@crisptrutski crisptrutski requested a review from a team January 30, 2024 11:10
Copy link
Contributor

@calherries calherries left a comment

Choose a reason for hiding this comment

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

LGTM

@crisptrutski crisptrutski merged commit 5ec3e3b into master Feb 2, 2024
107 checks passed
@crisptrutski crisptrutski deleted the evaluate-settings-options-at-runtime branch February 2, 2024 10:13
Copy link

github-actions bot commented Feb 2, 2024

@crisptrutski Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

metabase-bot bot added a commit that referenced this pull request Feb 2, 2024
Co-authored-by: Chris Truter <crisptrutski@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Automatically create PR on current release branch on merge .Team/BackendComponents also known as BEC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants