curved-television-6568
11/29/2022, 7:08 PMhundreds-father-404
11/29/2022, 7:09 PMproud-dentist-22844
11/29/2022, 7:09 PMcurved-television-6568
11/29/2022, 7:10 PMproud-dentist-22844
11/29/2022, 7:11 PMbitter-ability-32190
11/29/2022, 7:13 PMcurved-television-6568
11/29/2022, 7:13 PM__dependencies_rules__(
*{
python_sources: ("src/foo", "src/bar", "!*"),
(files, resources): ("res/**", "!*"),
}.items()
)
bitter-ability-32190
11/29/2022, 7:13 PMproud-dentist-22844
11/29/2022, 7:14 PMbitter-ability-32190
11/29/2022, 7:14 PMdict
prevents duplicate keyscurved-television-6568
11/29/2022, 7:16 PMbitter-ability-32190
11/29/2022, 7:17 PMcurved-television-6568
11/29/2022, 7:17 PMsuspect our default schema for things is orderedwhat’s this?
bitter-ability-32190
11/29/2022, 7:18 PMcurved-television-6568
11/29/2022, 7:19 PMhappy-kitchen-89482
11/29/2022, 7:40 PMproud-dentist-22844
11/29/2022, 7:50 PM__dependencies_rules__(
(
("python_*", "src/foo", "src/bar", "!*"),
("*", "res/**", "!*"),
)
)
so, we have a series of globs - The first glob is for target types, and the others are path globs. But, nothing indicates that they are not all globbing files. A dict highlights that there is a relationship between one glob (or glob tuple) and the other globs.__dependencies_rules__(
(
{"type": "python_*", "paths": ("src/foo", "src/bar", "!*")},
{"type": "*", "paths": ("res/**", "!*")},
)
)
If that’s valid, then I’ll probably use that all the time so it is easier to grok for newcomers to pants (which is basically everyone in the StackStorm community).bitter-ability-32190
11/29/2022, 7:54 PMcurved-television-6568
11/29/2022, 8:43 PM__dependencies_rules__(
(
({"type": "python_*"}, "src/foo", "src/bar", "!*"),
({"type": "*"}, ("res/**", "!*")), # you may group the rules though..
({"type": "file*", "path": "*.py"}, (...)),
)
)
proud-dentist-22844
11/29/2022, 8:44 PMcurved-television-6568
11/29/2022, 8:45 PMproud-dentist-22844
11/29/2022, 8:47 PMbitter-ability-32190
11/29/2022, 8:48 PMcurved-television-6568
11/29/2022, 8:51 PMDoes the syntatic sugar add much value? I’m afraid of using something obtuse.
Though I suppose in a corporate env, “training” and “that’s how we do it here” is the way we do it.I guess clarity over conciseness goes a long way in distributed project like st2, but in a closed corp env with a manageable sized group of ppl, training and later on-boarding for new hires will be required regardless and then the more concise syntax is more readable (in my eyes, guess that’s highly individual)
# As a common rule, apps may only depend on current subtree, own models, templates, common and 3rd party libs.
APP_RULES = (
"./**",
"/models/**",
"/../common/**",
"/../djcommon/**",
"/../templates/**",
"//3rdparty/python*",
"!*",
)
__dependencies_rules__(
(
# Users admin may depend on anything.
"[/admin.py]", "*",
),
(
# Users permissions is an exception to the rules, as it may depend on deal models.
"[/permissions.py]",
"/../deals/models/**",
APP_RULES,
),
(
# Viewsets and urls may depend on anything in the current app
(
"[/viewsets/**]",
"[/urls/**]",
),
"/**",
APP_RULES,
),
(
# Libs, serializers and tasks may depend on anything in the current app except viewsets and urls
(
"[/libs/**]",
"[/serializers/**]",
"[/tasks/**]",
),
"!/viewsets/**",
"!/urls/**",
"/**",
APP_RULES,
),
(
# Everything else must follow the common app rules
"*",
APP_RULES,
),
)
[]
for the selectors, make them stand out from the rules..bitter-ability-32190
11/29/2022, 8:57 PMcurved-television-6568
11/29/2022, 8:59 PM# As a common rule, apps may only depend on current subtree, own models, templates, common and 3rd party libs.
APP_RULES = (
"./**",
"/models/**",
"/../common/**",
"/../djcommon/**",
"/../templates/**",
"//3rdparty/python*",
"!*",
)
__dependencies_rules__(
(
# Users admin may depend on anything.
{"path": "/admin.py"}, "*",
),
(
# Users permissions is an exception to the rules, as it may depend on deal models.
{"path": "/permissions.py"},
"/../deals/models/**",
APP_RULES,
),
(
# Viewsets and urls may depend on anything in the current app
(
{"path": "/viewsets/**"},
{"path": "/urls/**"},
),
"/**",
APP_RULES,
),
(
# Libs, serializers and tasks may depend on anything in the current app except viewsets and urls
(
{"path": "/libs/**"},
{"path": "/serializers/**"},
{"path": "/tasks/**"},
),
"!/viewsets/**",
"!/urls/**",
"/**",
APP_RULES,
),
(
# Everything else must follow the common app rules
{},
APP_RULES,
),
)
bitter-ability-32190
11/29/2022, 9:00 PMcurved-television-6568
11/29/2022, 9:02 PM# As a common rule, apps may only depend on current subtree, own models, templates, common and 3rd party libs.
APP_RULES = (
"./**",
"/models/**",
"/../common/**",
"/../djcommon/**",
"/../templates/**",
"//3rdparty/python*",
"!*",
)
__dependencies_rules__({
# Users admin may depend on anything.
"[/admin.py]": "*",
# Users permissions is an exception to the rules, as it may depend on deal models.
"[/permissions.py]": (
"/../deals/models/**",
APP_RULES,
),
# Viewsets and urls may depend on anything in the current app
(
"[/viewsets/**]",
"[/urls/**]",
): (
"/**",
APP_RULES,
),
# Libs, serializers and tasks may depend on anything in the current app except viewsets and urls
(
"[/libs/**]",
"[/serializers/**]",
"[/tasks/**]",
): (
"!/viewsets/**",
"!/urls/**",
"/**",
APP_RULES,
),
# Everything else must follow the common app rules
"*": APP_RULES,
})
bitter-ability-32190
11/29/2022, 9:03 PMPathRule(...)
vs TypeRule(...)
curved-television-6568
11/29/2022, 9:03 PMbitter-ability-32190
11/29/2022, 9:04 PMcurved-television-6568
11/29/2022, 9:06 PM# As a common rule, apps may only depend on current subtree, own models, templates, common and 3rd party libs.
APP_RULES = (
"./**",
"/models/**",
"/../common/**",
"/../djcommon/**",
"/../templates/**",
"//3rdparty/python*",
"!*",
)
__dependencies_rules__(
RuleSet(
# Users admin may depend on anything.
select_for=("[/admin.py]",),
rules=("*",),
),
RuleSet(
# Users permissions is an exception to the rules, as it may depend on deal models.
select_for=("[/permissions.py]",),
rules=(
"/../deals/models/**",
APP_RULES,
),
),
RuleSet(
# Viewsets and urls may depend on anything in the current app
select_for=(
"[/viewsets/**]",
"[/urls/**]",
),
rules=(
"/**",
APP_RULES,
)
),
RuleSet(
# Libs, serializers and tasks may depend on anything in the current app except viewsets and urls
select_for=(
"[/libs/**]",
"[/serializers/**]",
"[/tasks/**]",
),
rules=(
"!/viewsets/**",
"!/urls/**",
"/**",
APP_RULES,
)
),
RuleSet(
# Everything else must follow the common app rules
select_for=("*",),
rules=APP_RULES,
),
)
def RuleSet(select_for, rules):
return (select_for, rules)
Path
and TargetType
etc…bitter-ability-32190
11/29/2022, 9:11 PMcurved-television-6568
11/29/2022, 9:11 PMbitter-ability-32190
11/29/2022, 9:12 PMcurved-television-6568
11/29/2022, 9:12 PMduplicate key behaviorif it comes down to that being a deciding factor, we could add a check that there should not be two identical selectors across all rule sets…
proud-dentist-22844
11/29/2022, 9:17 PM({...}, ...)
format for rules.bitter-ability-32190
11/29/2022, 9:20 PMproud-dentist-22844
11/29/2022, 9:24 PMcurved-television-6568
11/29/2022, 9:25 PMI’ll maintain this entire thing seems very DSL-shoved-into-a-round-hole to meThat’s the thing, it’s not a DSL, but pure Python… which gives me the idea that perhaps it ought to be a DSL, and as such live in a dedicated file outside of BUILD files… 😄
bitter-ability-32190
11/29/2022, 9:26 PM__dependencies_rules__({
# Users admin may depend on anything.
PathRule("/admin.py]): "*",
# Users permissions is an exception to the rules, as it may depend on deal models.
PathRule("/permissions.py"): (
"/../deals/models/**",
APP_RULES,
),
# Viewsets and urls may depend on anything in the current app
(
PathRule"/viewsets/**"),
PathRule("/urls/**"),
): (
"/**",
APP_RULES,
),
# Libs, serializers and tasks may depend on anything in the current app except viewsets and urls
(
PathRule("/libs/**"),
PathRule("/serializers/**"),
PathRule("/tasks/**"),
): (
"!/viewsets/**",
"!/urls/**",
"/**",
APP_RULES,
),
# Everything else must follow the common app rules
"*": APP_RULES,
# (Made up)
TargetRule(python_source): ...
})
curved-television-6568
11/29/2022, 9:26 PM.gitignore
file, but with a different name (and syntax)bitter-ability-32190
11/29/2022, 9:26 PMSQLAlchemy
is DSL-esquehappy-kitchen-89482
11/29/2022, 9:27 PMcurved-television-6568
11/29/2022, 9:27 PMbitter-ability-32190
11/29/2022, 9:29 PMcurved-television-6568
11/29/2022, 9:30 PMbitter-ability-32190
11/29/2022, 9:30 PMcurved-television-6568
11/29/2022, 9:32 PMPathRule"/viewsets/**"),
doesn’t, to me say what it does. It’s a PathRule, but what does that mean?bitter-ability-32190
11/29/2022, 9:32 PM[somepath]
tells me even lesscurved-television-6568
11/29/2022, 9:33 PMproud-dentist-22844
11/29/2022, 9:34 PMrule[1:] if rule[0]
curved-television-6568
11/29/2022, 9:35 PMvisibility
field 😮proud-dentist-22844
11/29/2022, 9:36 PMcurved-television-6568
11/29/2022, 9:36 PMbitter-ability-32190
11/29/2022, 9:36 PMJust leave it as is so we can get it ASAPThat thinking makes me uncomfortable
curved-television-6568
11/29/2022, 9:37 PMbitter-ability-32190
11/29/2022, 9:38 PMcurved-television-6568
11/29/2022, 9:38 PMbitter-ability-32190
11/29/2022, 9:38 PMcurved-television-6568
11/29/2022, 9:38 PMbitter-ability-32190
11/29/2022, 9:38 PMcurved-television-6568
11/29/2022, 9:39 PMbitter-ability-32190
11/29/2022, 9:39 PMcurved-television-6568
11/29/2022, 9:40 PMbitter-ability-32190
11/29/2022, 9:40 PMcurved-television-6568
11/29/2022, 9:42 PMproud-dentist-22844
11/29/2022, 9:42 PM__dependency_rules__
and __dependents_rules__
The implementation is in an experimental plugin.curved-television-6568
11/29/2022, 9:42 PM__dependencies_rules__(
"src/foo/bar/*", # allow src/foo/bar/* for everything
( # start rule group, only for files and resources
[resources, files],
"static/**/*.res",
"static/**/*.txt",
),
(
"tests/common/**", # applies for all targets/paths
[python_tests], # any non-python_tests will exit this rule group here
"tests/python/**", # only python_tests will have this rule
),
"!*", # ALL will have this rule
)
I think this will allow reducing duplication in rules, by sharing common “rule sets”.bitter-ability-32190
11/29/2022, 10:16 PMcurved-television-6568
11/29/2022, 10:16 PMbitter-ability-32190
11/29/2022, 10:19 PMcurved-television-6568
11/29/2022, 10:20 PM("*", …)
to mean, apply the …
rules to all targets