Repository navigation
feat: apply ignore metadata on directory flags from the CLI - #8436
Conversation
|
I still need to write tests for them, will do tomorrow! |
d222af3 to
6d78676
Compare
|
Test added, however the CI look super bad, I'm trying to make it green |
d021cb0 to
e8e4346
Compare
f9564ee to
87e0b56
Compare
|
I don't think it's |
| if len(arg.metadata.Ignore) > 0 { | ||
| converted, err = fn.applyIgnoreOnDir(ctx, opts.Server, arg.metadata, converted) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to apply ignore pattern on arg %q: %w", input.Name, err) | ||
| } | ||
| } |
There was a problem hiding this comment.
For a directory provided via CLI, and uploaded via bk.LocalImport, this will filter the resulting directory another time, but with this, right?
{
directory {
withDirectory(path: "/", directory: "<ID>", exclude: ["<same ignore pattterns>"])
}
}I'd rather find a fix so it doesn't filter twice, before enabling this for all directories. Simply having support for the CLI is enough to deprecate views.
This is what's causing the issue with sdk/python/dev by the way.
There was a problem hiding this comment.
For a directory provided via CLI, and uploaded via bk.LocalImport, this will filter the resulting directory another time, but with this, right?
You're right, so you suggest that for now, we only applied //+ignore when the module is called from the CLI?
There was a problem hiding this comment.
Looks like it fixed the issue! I'm trying to get the CI green and then we can do the ignore process in a follow up
There was a problem hiding this comment.
Hm, I disagree here - I think the filtering twice is frustrating from a performance point of view, but I'd rather that than have entirely different behavior when invoking from the CLI vs from another module.
Is your concern just performance @helderco? Or is there a correctness concern here as well?
As a suggestion, the way to track this would be add a field to Directorys that indicate which ignore patterns were used during resolveDirectoryFromCaller. Then we just check if those were equal to the patterns specified here, and if they are, we can skip the applyIgnoreOnDir.
This should be pretty simple, it just needs to be plumbed through?
There was a problem hiding this comment.
Hm, I disagree here - I think the filtering twice is frustrating from a performance point of view, but I'd rather that than have entirely different behavior when invoking from the CLI vs from another module.
That's fair, I'm just willing to release filtering from the CLI first depending on how long it will take to handle both use cases correctly since I think that's much more important and immediately useful to people. It's at the boundary from host to engine, so that's where users are reporting issues with slowness.
Is your concern just performance @helderco? Or is there a correctness concern here as well?
There's a correctness concern, yes. I was going to ask some questions on the implementation but noticed it was the cause of the failing checks due to sdk/python/dev.
There's also the performance concern, but only secondary. The main problem for me there is that it forces a copy (withDirectory), so for users with big directories this could be quite noticeable. I know withDirectory can do a mergeOp if the path in both directories is /. Maybe it is that, when using resolveFromCaller, but haven't actually checked or tested with a big file.
As a suggestion, the way to track this would be add a field to
Directorys that indicate whichignorepatterns were used duringresolveDirectoryFromCaller. Then we just check if those were equal to the patterns specified here, and if they are, we can skip theapplyIgnoreOnDir.
Yeah, I suggested the same thing in sync last week.
This should be pretty simple, it just needs to be plumbed through?
Yeah, I'm all for it if @TomChv can make both work not only correctly (i.e., even if filtered twice, there should be no difference in the result), but also without the performance hit on the copy for heavy directories.
| if len(args.Ignore) > 0 { | ||
| excludes = append(excludes, args.Ignore...) | ||
| } | ||
|
|
There was a problem hiding this comment.
I don't think this is a good idea. When specifying a view:
dagger call --source=.:default source
This code is adding the patterns from the view, with different semantics from // +ignore because of the split into exclude/include based on !, and adding the // +ignore patterns on top.
I think it's less surprising if you apply one or the other. Basically let a view override the patterns from code, instead of acting as a default.
There was a problem hiding this comment.
This code is adding the patterns from the view, with different semantics from // +ignore because of the split into exclude/include based on !, and adding the // +ignore patterns on top.
And also because orders matter, it might totally break the expect result.
|
I'm trying your suggestion, see if it fixes my issues |
| // Disable for now until we figure out how to not "double-ignore" arguments from CLI | ||
| // if len(arg.metadata.Ignore) > 0 { | ||
| // converted, err = fn.applyIgnoreOnDir(ctx, opts.Server, arg.metadata, converted) | ||
| // if err != nil { | ||
| // return nil, fmt.Errorf("failed to apply ignore pattern on arg %q: %w", input.Name, err) | ||
| // } | ||
| // } |
There was a problem hiding this comment.
Why are we disabling this?
What's the issue with the double-ignore? My expectation is that this would work right? It's just that we would not actually end-up excluding things, so it's slightly worse performance, but it would still do the expected thing right?
If it's just that, we should enable it, leave a note, and come back and optimize later by fixing the "double-ignore" issue.
There was a problem hiding this comment.
Because of this: #8436 (comment), but I think I'll just remove that part of the code since I talked with Helder and he said it wasn't very important to support ignore in module to module
There was a problem hiding this comment.
Removed in d974dcb, supporting ignore from module to module will be done in a follow up later.
There was a problem hiding this comment.
Why are we disabling this?
The implementation didn't seem to correctly handle the ignore patterns in /sdk/python/dev when used as a dependency in /.dagger (missing pyproject.toml for example). I suggested releasing the CLI use case first, depending on how long it would take to do this properly for all directories, since users are reporting slowness there.
| return nil | ||
| } | ||
|
|
||
| // func (fn *ModuleFunction) applyIgnoreOnDir(ctx context.Context, dag *dagql.Server, arg *FunctionArg, value any) (any, error) { |
There was a problem hiding this comment.
We should avoid committing commented code - it simply ends up getting out of date with the rest of the code.
| body: |- | ||
| Apply `ignore` function parameter metadata on any Directory passed from the CLI. | ||
|
|
||
| This extends the usage of `ignore` to not only dir loaded with `defaultPath` but any directory passed as function's param. |
There was a problem hiding this comment.
See #8436 (comment) - I think we should ship both of these together, it's a weird functionality gap to only do one of them (especially given it doesn't seem tricky to do them at the same time?)
But if we decide to ship them separately, then this sentence should be rephrased for clarity - it's not any directory passed as a function param, it's only for directories passed on the CLI.
There was a problem hiding this comment.
(especially given it doesn't seem tricky to do them at the same time?)
Yes the function I did was quite simple but it broke all the tests for a weird reason where python had missing file, Helder suggested to disable the double ignore and it fixed the issue.
I'll update the release note
|
The lint error doesn't seem related to my changes, I'm trying locally to see if I can repro |
jedevc
left a comment
There was a problem hiding this comment.
SGTM, won't block on a full module implementation - but we should follow-up with the asap.
c10302b to
4341cc5
Compare
Update `ModuleFunction.setCallInputs` to apply ignore patterns on `Directory` that have `ignore` as metadatas. Update `ResolveDirectoryFromCaller` arguments to supports optional ignore argument. Update CLI `Directory` handling to also apply ignore on Directory if `ignore` is set. Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
Signed-off-by: Tom Chauveau <[email protected]>
4341cc5 to
dbd0539
Compare

Closes #7832
Update
ModuleFunction.setCallInputsto apply ignore patterns onDirectorythat haveignoreas metadatas.Update
ResolveDirectoryFromCallerarguments to supports optional ignore argument.Update CLI
Directoryhandling to also apply ignore on Directory ifignoreis set.Still need to add tests, I only manually tested now: Test addedExample with Typescript: