Replies: 2 comments 5 replies
-
This is very useful for me to know what to develop further on, thank you! I wasn't aware of tach being abandoned, and have thought of the features there as something teams could use in addition to what the Polylith tooling offers. I'll read your post more carefully later this week, to identify what the low hanging fruits might be. |
Beta Was this translation helpful? Give feedback.
-
Adding some notes here as I read your summary: tach check and poly check seems very similar (but I haven't read up on the details on tach yet).
I have thought of adding data about "interfaces", in a similar way as with the Clojure version of the poly tool. The way I see "interface" in Python and for Polylith bricks would be the The tach report looks very much like an equivalent to |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey David, back with some thoughts!
Are you aware of
tach
? We adopted it very early on in our monorepo as a great tool to help us define and document dependencies between components. the issue:tach
is abandoned now by their makers. And to me it looks like that at least part of their functionality is very close to what the polylith tooling is already checking under the hood.This issue serves to describe some of the core commands of tach (check and report) and to explore if there would be any interest to build this either into or on top of polylith-cli!
The basics of tach
The basic idea of
tach
the way we use it is that one defines a file calledtach.toml
which describes for each module which other modules it is allowed to import from. It by design limits itself to direct imports, not transitive imports.Such a file does serve as a way of documenting the desired architecture patterns and make it very explicit which component imports from which other component.
A small example:
this is a snippet of our monorepo. It defines that the
api_client
component does depend on two other components,constants
andtime_series_standards
. These two other components might depend on other components, buttach
does not specify if they do.tach check
: enforce boundariesThe core command of
tach
istach check
. This does the following:tach.toml
tach check
Example 1Suppose I did not add the
constants
module to thetach.toml
file section above, but am importing fromconstants
in the code of theapi_client
component. If I now runtach check
I will get a detailed list of errors, specifying where inapi_client
I use a module that is not allowed:This is very useful in the following cases:
tach check
helps me to think twice. And it also makes it extremely easy for a code reviewer on an MR to see if somebody has added new coupling in the codebase - just check if tach.toml has been changed (tach check
runs in CI so it is not possible to commit something wheretach.toml
does not reflect the state of the code base).tach.toml
, then runtach check
, and then go through the list of issues one by one.tach check
Example 2suppose I define in
tach.toml
that I am allowed to import from a module calledsettings
but in practice I do not. In such a case, if the tool is configured tostrict
, it will also report this as an error:tach report
: report dependenciesAnother very helpful command is
tach report
. It reports in detail which dependencies are detected in a specific module.Output example below:
This is another very useful style of outputting a detailed report on the dependencies of a module. Running
poly deps --brick bo_backtest
gives me something similar in concept but different in output style:In some cases the
poly deps
output is enough already. I notice that in my repo, to look up that information, I default to searching in mytach.toml
file to quickly get a similar result. The corresponding lines intach.toml
are:When I want more detailed info, I run the
tach report
command as mentioned above.Other
tach
commandsThere is more to
tach
, there are ideas around visualization, features around third party dependencies, selective test running (extremely useful and implemented slightly different (less opinionated and better imo) thanpoly test
), etc. but that is for now beyond the scope of this post. The core functionality is what I described above: thetach check
command, which takes thetach.toml
file and compares it against the actual structure as observed from the code/the AST.Summary and ideas forward
Long story short: I see clear overlaps between what the
poly
tooling is already doing, and the functionality intach
that I love and use on a daily basis - buttach
is abandoned. If I want to get rid oftach
and leverage the existing work done inpoly
, I see several potential ways forward, in increasing degrees of collaboration - all depending on whether you feel this is interesting or in scope at all, and have the time and interest to invest in this:poly
, similar to what I did here, building on non-public API parts of polylithpython-polylith
and work from therepolylith
more flexibly - using the core functionality but having more freedom to build specific things on top. In that scenario, I could try to build thetach
-like setup as a layer on top ofpython-polylith
and maybe publish it open source.tach
gets fully absorbed intopoly
.Very curious to hear what you think!
Beta Was this translation helpful? Give feedback.
All reactions