-
Notifications
You must be signed in to change notification settings - Fork 54
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
The sequential
example in the docs doesn't work
#156
Comments
good catch in the docs. The error message is trying to explain that most patterns are auto wrapped https://docs.grit.io/language/bubble#pattern-auto-wrap sequential is not auto wrapped because it only matches on files, so the pattern inside of a sequential needs to match a top level file. in this case the easy fix is to insert a contains in front of each step like so:
|
Are there other strategies besides using |
The core thing is that each step is matching the file as a whole. In most cases, you want to look for some code inside the file so |
@morgante This may be another bug, or some misunderstanding from my side. The following grit code.
Seems to replace the first self in a function. While the following grit code
replaces all the self in the python code of the file. So clearly just using the construct with bubble and contains are not equivalent. Python code to use. class AlertTest(BaseTest):
@vcr.use_cassette
def test_rule(self):
resp = self.get("/url/alert/rule")
self.assertEqual(resp.status_code, 200)
@vcr.use_cassette
def test_alert_search(self):
resp = self.post(
"/url/alert/search",
data={
"alert_rule": "oeuoeu",
"use_case": "usecase",
"panels": "count,rules,details",
},
)
self.assertEqual(resp.status_code, 200) |
The bubble needs to go around the scope you actually want to isolate, like this:
|
@morgante Thank you. contains
In other words it is using bubble the very first. Also I'm noticing that Ie the following code does not work as expected finding zero matches. Though each sequence in separation does work as expected.
Some feedback regarding The way I conceptualize sequential is a loop, so that each statement is applied on the file in question. Right now if you have a series of statements and one of the statements doesn't match, nothing at all is changed on the file. That makes it difficult to debug, but also it may be desirable to apply the series of transformations and if one doesn't match it would still apply the other transformations. I would rather get a warning message saying that the following statement was had no match in xxx file, and thus no transformation happened there. Also it would be nice if no extra syntax was needed to stay consistent with single statement transformations. |
When you try the following pattern described in the docs for sequential it doesn't work in the studio.
You also get the following warning.
This warning is somewhat unclear, as it doesn't really tell the user how they should proceed to make things work the way they expect it to.
The text was updated successfully, but these errors were encountered: