uranusjr commented on code in PR #34118:
URL: https://github.com/apache/airflow/pull/34118#discussion_r1316528170


##########
airflow/providers/amazon/aws/operators/sagemaker.py:
##########
@@ -166,9 +166,8 @@ def hook(self):
     def path_to_s3_dataset(path) -> Dataset:
         from openlineage.client.run import Dataset
 
-        path = path.replace("s3://", "")
-        split_path = path.split("/")
-        return Dataset(namespace=f"s3://{split_path[0]}", 
name="/".join(split_path[1:]), facets={})
+        namespace, _, name = path[len("s3://") :].partition("/")
+        return Dataset(namespace=f"s3://{namespace}", name=name, facets={})

Review Comment:
   I wonder if it’d be easier to just use `urllib.parse.urlsplit` here



##########
airflow/providers/amazon/aws/operators/sagemaker.py:
##########
@@ -166,9 +166,8 @@ def hook(self):
     def path_to_s3_dataset(path) -> Dataset:
         from openlineage.client.run import Dataset
 
-        path = path.replace("s3://", "")
-        split_path = path.split("/")
-        return Dataset(namespace=f"s3://{split_path[0]}", 
name="/".join(split_path[1:]), facets={})
+        namespace, _, name = path[len("s3://") :].partition("/")
+        return Dataset(namespace=f"s3://{namespace}", name=name, facets={})

Review Comment:
   I wonder if it’d be easier to just use `urllib.parse.urlsplit` here



-- 
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]

Reply via email to