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
metabase.search
namespace
#42487
metabase.search
namespace
#42487
Conversation
dev/src/dev/deps_graph.clj
Outdated
@@ -56,3 +56,50 @@ | |||
"All namespaces from a module that are used outside that module." | |||
[module-symb] | |||
(into (sorted-set) (map :depends-on-namespace) (external-usages module-symb))) | |||
|
|||
(defn module-dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some extra new dev tools to help me find circular references between modules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave some feedback on this in the other PR that used it, in case you were planning on merging this one first.
@@ -246,70 +244,69 @@ | |||
[& args] | |||
(apply search-request-data-with identity args)) | |||
|
|||
(deftest order-clause-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to metabase.search.impl-test
@@ -900,50 +919,6 @@ | |||
(t2/update! Pulse (:id pulse) {:dashboard_id (:id dashboard)}) | |||
(is (= nil (search-for-pulses pulse)))))))))) | |||
|
|||
(deftest search-db-call-count-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to metabase.search.impl-test
@@ -1312,173 +1292,7 @@ | |||
(is (= "Failed to parse datetime value: today~" | |||
(mt/user-http-request :crowberto :get 400 "search" :q search-term :last_edited_at "today~" :creator_id (mt/user->id :rasta)))))))) | |||
|
|||
(deftest created-at-correctness-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to metabase.search.impl-test
@@ -788,15 +788,15 @@ | |||
:status status}))) | |||
(thunk))) | |||
|
|||
(defmacro with-verified-cards | |||
(defmacro with-verified-cards! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not ok in ^:parallel
tests so I gave it a !
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man, so nice that you encapsulated the search code like this. We're about to start working on this module to put the "search engine" behind of plugable interface, so the timing couldn't be better.
dev/src/dev/deps_graph.clj
Outdated
@@ -56,3 +56,50 @@ | |||
"All namespaces from a module that are used outside that module." | |||
[module-symb] | |||
(into (sorted-set) (map :depends-on-namespace) (external-usages module-symb))) | |||
|
|||
(defn module-dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gave some feedback on this in the other PR that used it, in case you were planning on merging this one first.
src/metabase/db/connection.clj
Outdated
resources. This seems to be the default this is the default for Postgres, but MySQL/MariaDB seem to default to | ||
`HOLD_CURSORS_OVER_COMMIT`." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resources. This seems to be the default this is the default for Postgres, but MySQL/MariaDB seem to default to | |
`HOLD_CURSORS_OVER_COMMIT`." | |
resources. This this is the default for Postgres, but MySQL/MariaDB seem to default to `HOLD_CURSORS_OVER_COMMIT`." |
src/metabase/db/connection.clj
Outdated
(doto (.getConnection data-source) | ||
(setup-connection!)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
src/metabase/db/connection.clj
Outdated
;; otherwise we don't need our savepoint anymore and we can release it. | ||
(.releaseSavepoint connection savepoint)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
src/metabase/db/connection.clj
Outdated
(try | ||
(.rollback connection savepoint) | ||
(catch Throwable e2 | ||
(log/errorf e2 "Error rolling back transaction: %s (triggered by: %s)" (ex-message e2) (ex-message e)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
;; TODO FIXME -- search actually currently still requires [[metabase.api.common/*current-user*]] to be bound, | ||
;; because [[metabase.public-settings.premium-features/sandboxed-or-impersonated-user?]] requires it to be bound. | ||
;; Since it's part of the search context it would be nice if we could run search without having to bind that stuff at | ||
;; all. | ||
(assert @@(requiring-resolve 'metabase.api.common/*current-user*) | ||
"metabase.api.common/*current-user* must be bound in order to use search for an indexed entity") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the detailed explanation and validation 🙏
Out of curiosity, did you check how much all this parallelism speeds up tests locally / in CI? |
@camsaul reviewing this now, but just a thought - as far as I can tell, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for parallelizing all those tests, that's awesome!
Changes all LGTM, but I do kind of think metabase.search
should probably live under metabase.api.search
, so I'd honestly rather move things in the reverse direction here, unless we can think of a good reason why other parts of the system might want to use a metabase.search
module. Especially since e.g. there are functions like metabase.search.scoring/serialize
(which honestly, I don't know why it lives there in the first place, but nevertheless...) which seem to be pretty intimately connected to sending data to an API client.
We're about to modularize search, so it's going to have a few backends, and models will have to implement some protocol to be searchable — so it doesn't seem like moving it under |
Alright, that makes sense then - thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
, but a significant chunk of search implementation stuff lived in metabase.api.search. I moved all of that stuff out into a new metabase.search.impl namespace
👏
(test-search "past1years-from-12months" old-result) | ||
(test-search "today" new-result)))))) | ||
|
||
(deftest last-edited-at-correctness-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to metabase.search.impl-test
@camsaul Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
* Search API namespace * Search API namespace * Search API namespace * Fix Kondo warnings * Fix typo * Finally solve the MySQL ^:parallel test failures <3 * Make some search tests REPL-friendly * Did I finally fix `^:parallel` MySQL tests? * Ok I give up just make the search tests single-threaded for MySQL/MariaDB. * Revert the stuff to make paralell tests work for MySQL... for now. * Keep new name * Revert deps-graph changes * Remove unused namespaces * Fix Kondo linter for log/info + format * Misc fixes 🔧 * Test fixes 🔧
Consolidate search into a
metabase.search
module. Most of the important stuff related to search already lived inmetabase.search
namespaeces, but a significant chunk of search implementation stuff lived inmetabase.api.search
. I moved all of that stuff out into a newmetabase.search.impl
namespace, so now the search module exists completely independently of the REST API. I removed search's dependency onmetabase.api/*current-user-id*
and made it part of the search context instead (for some reason:current-user-perms
was already part of search context but current User ID was not). This is so there are no circular deps between themetabase.search
andmetabase.api
modules.2I moved some of the tests over but there is probably more work to do there still.
Also I couldn't help myself and split a bunch of big tests into smaller ones and marked them
^:parallel
where it made sense.