Copilot commented on code in PR #6641: URL: https://github.com/apache/texera/pull/6641#discussion_r3617819682
########## amber/src/test/python/core/storage/test_vfs_uri_factory.py: ########## @@ -0,0 +1,140 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import pytest + +from core.storage.vfs_uri_factory import VFSResourceType, VFSURIFactory +from proto.org.apache.texera.amber.core import ( + ExecutionIdentity, + GlobalPortIdentity, + OperatorIdentity, + PhysicalOpIdentity, + PortIdentity, + WorkflowIdentity, +) + + +def _gpi( + op_id: str = "myOp", + layer: str = "main", + port: int = 0, + internal: bool = False, + is_input: bool = True, +) -> GlobalPortIdentity: + return GlobalPortIdentity( + op_id=PhysicalOpIdentity( + logical_op_id=OperatorIdentity(id=op_id), layer_name=layer + ), + port_id=PortIdentity(id=port, internal=internal), + input=is_input, + ) + + +class TestCreatePortBaseUri: + def test_base_uri_encodes_scheme_ids_and_serialized_port(self): + uri = VFSURIFactory.create_port_base_uri( + WorkflowIdentity(id=7), ExecutionIdentity(id=3), _gpi() + ) + # The base URI stitches together the vfs scheme, the wid/eid segments, + # and the serialized global port identity as a single trailing segment. + assert uri == ( + "vfs:///wid/7/eid/3/globalportid/" + "(logicalOpId=myOp,layerName=main,portId=0," + "isInternal=false,isInput=true)" + ) + + def test_result_uri_appends_result_segment(self): + base = VFSURIFactory.create_port_base_uri( + WorkflowIdentity(id=1), ExecutionIdentity(id=1), _gpi() + ) + assert VFSURIFactory.result_uri(base) == f"{base}/result" + + def test_state_uri_appends_state_segment(self): + base = VFSURIFactory.create_port_base_uri( + WorkflowIdentity(id=1), ExecutionIdentity(id=1), _gpi() + ) + assert VFSURIFactory.state_uri(base) == f"{base}/state" + + +class TestDecodeUriRoundTrip: + def test_result_uri_round_trips_through_decode(self): + wid, eid, gpi = WorkflowIdentity(id=42), ExecutionIdentity(id=9), _gpi( + op_id="opA", layer="main", port=2, internal=True, is_input=False + ) + base = VFSURIFactory.create_port_base_uri(wid, eid, gpi) + uri = VFSURIFactory.result_uri(base) + Review Comment: `VFSURIFactory.decode_uri()` lowercases the final path segment before converting it to `VFSResourceType`, but `VFSResourceType` includes camelCase values (`runtimeStatistics`, `consoleMessages`). This means URIs ending with `/runtimestatistics` or `/consolemessages` (the format produced by the Scala VFSURIFactory) will currently raise `ValueError("Unknown resource type")` in Python. Consider adding unit coverage for these resource types and adjusting `decode_uri` to do a case-insensitive match against enum values (e.g., compare `t.value.lower()`), so the Python decoder stays compatible with existing URIs. -- 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]
