If I have a rule that takes a dataclass A as input...
# development
a
If I have a rule that takes a dataclass A as input and I send it dataclass B which is a subclass of A, will it come through to the rule as B or does the engine convert it to the superclass when it serializes it for caching?
Also wondering when 2.32 is slated to leave dev? I've been swamped with other stuff and am only just now catching up on finishing the
buildctl
integration I was working on.
Gonna try and finish it before I leave for vacation next Thursday.
w
Also wondering when 2.32 is slated to leave dev?
Shortly. It was just waiting on https://github.com/pantsbuild/scie-pants/pull/509 to drop
h
I believe this is relevant to your first question. An instance of B and an instance of A will be considered non-equal, even if they are equal on all superclass fields, for the purpose of memoization of rules. But this is in-memory, and there is no serialization as far as I can remember, so you'll get back whatever the rule emitted when it was memoized (I think - worth testing!) Note that on-disk caching is just for running Processes, and Process/ProcessResult are Rust structs that are populated from and to the corresponding Python equivalents. So subclassing them on the Python side won't have any effect.
c
Note that on-disk caching is just for running Processes,
I was confused by this recently too. I convinced myself on disk was "just" a process cache, but I'm not following what these other two types are:
Copy code
enum CacheKeyType {
  PROCESS = 0;
  URL = 1;
  DEP_INFERENCE_REQUEST = 2;
}
https://github.com/pantsbuild/pants/blob/9b3c1562e2081d8e60433341ad8dc5585ec37323/src/rust/protos/protos/pants/cache.proto#L7
h
Ah yes, those are two special cases for native implementation of URL fetching and of dep inference. Those are also cached on disk without going through the Process mechanism
but general dataclasses are not cached on disk