aglinxinyuan commented on code in PR #5706:
URL: https://github.com/apache/texera/pull/5706#discussion_r3409065201
##########
amber/src/main/python/core/util/virtual_identity.py:
##########
@@ -24,16 +24,32 @@
ActorVirtualIdentity,
)
-worker_name_pattern = re.compile(r"Worker:WF\d+-.+-(\w+)-(\d+)")
+worker_name_pattern = re.compile(r"Worker:WF(\d+)-(.+)-(\w+)-(\d+)")
MATERIALIZATION_READER_ACTOR_PREFIX = "MATERIALIZATION_READER_"
def get_worker_index(worker_id: str) -> int:
- match = worker_name_pattern.match(worker_id)
+ match = worker_name_pattern.fullmatch(worker_id)
if match:
- return int(match.group(2))
- raise ValueError("Invalid worker ID format")
+ return int(match.group(4))
+ raise ValueError(f"Invalid worker ID format: {worker_id}")
+
+
+def get_operator_id(worker_id: str) -> str:
Review Comment:
Good call — the Scala side already has the equivalents in
`VirtualIdentityUtils`: `getPhysicalOpId` (returns
`PhysicalOpIdentity(OperatorIdentity(operator), layerName)`) and
`getWorkerIndex` (`Option[Int]`). This Python pair mirrors them — same
`Worker:WF(\d+)-(.+)-(\w+)-(\d+)` regex, and the docstring points at
`getPhysicalOpId`. `get_operator_id` is just the `.logicalOpId.id` half of it,
and `get_worker_index` matches `getWorkerIndex`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]