Repository navigation
fix(python): use unique module paths to avoid uv cache conflict - #8245
Conversation
|
My theory for how this affected CI more than local environments is related to disk throughput - I suspect with heavily busy enough engines, the disk could be maxed out, and we might end up having some read/write operations interleaved. This means that potentially with all these parallel python tests, we might end up with some of the calls to |
| id, err := m.Discovery.ModSource.ID(ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| h := sha256.New() | ||
| fmt.Fprint(h, id) | ||
| idHex := hex.EncodeToString(h.Sum(nil)) | ||
| m.SourcePath = path.Join(ModSourceDirPath, idHex) |
There was a problem hiding this comment.
Hm, this isn't the right stable ID to use - it should be related to the context directory I think?
For git sources, maybe we could use the commit ID? And for local sources, the Digest? Maybe we want a ModuleSource.digest property more generally for things like this.
There was a problem hiding this comment.
Maybe we want a
ModuleSource.digestproperty more generally for things like this.
I've found the need for a unique ID per module to use as a key for a cache volume, for node_modules and .venv, but was able to avoid it (just not creating a cache volume for it). So I agree that it can be useful in general.
We'll soon have isolated/namespaced cache volumes per module though. Even though that'll apply to the runtime module itself and not the target module, maybe the same approach that @sipsma is going for can be reused here, even if just the part that uniquely identifies a modules. Not sure if it's a simple namespace based on the module's name (like type namespaces) though.
There was a problem hiding this comment.
Isolated cache volumes for each SDK instance would I think solve this issue, but the problem then is that we wouldn't be able to cache any legitimately shared dependencies if they were entirely separated 😢
I guess the uv cache is just not designed to be shared across multiple hosts, so, we need some little trick just for those paths 😢
There was a problem hiding this comment.
Yeah, I know, I was saying maybe you can reuse some part of it, in order to get the unique value for the mount. Unless the idea for the namespaced cache valumes is to just use the module name.
There was a problem hiding this comment.
Oh right I see 🎉 🎉 (time for more coffee)
There was a problem hiding this comment.
I ended up implementing Directory.digest and ModuleSource.digest so I could have a better way of doing this.
For some reason, the ID kept changing, I'm guessing normalizeCallerLoadedSource isn't helping here? Having a Digest helps keep things a bit more consistent and content-based.
This comment was marked as resolved.
This comment was marked as resolved.
6ba1889 to
b4057c8
Compare
|
Gonna merge this now, let's see if this chunk of flakes is officially squashed! 🤞 |
|
Looks like this wasn't merged - I'm gonna hold it till after the release later today. |
b4057c8 to
05324b7
Compare
68ccb9f to
22e75df
Compare
I'm so confused, I swear I pressed merge... 😵💫 |
|
😱 okay, all the test failures are either flakes, or... the issue that the linter gets very sad when trying to codegen a feature in This is annoying, two options:
|
Probably would need to release the new digests in the API first, and then use it in the runtime right? However, I'm good with either options you provided until next release. Excluding from the linter is just easier though, but temporary anyway. |
22e75df to
1d4e6ea
Compare
|
Decided to revert to the older approach, and just deferred adding the |
1d4e6ea to
3b054ae
Compare
Signed-off-by: Justin Chadwell <[email protected]>
Attempts to fix #7662, follow-up to #8051.
I think #8051 was the right approach - however, the tests weren't the issue. The paths in the tests aren't actually part of the uv cache key, so the underlying issue remains.
The real fix for this needs to be in the python sdk runtime, where we can correctly set these paths - based on the module id (or some other "unique enough" id, that can guarantee that we're not going to get weird horrible conflicts).
cc @sipsma @helderco