You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "uranusjr (via GitHub)" <gi...@apache.org> on 2023/09/05 23:53:09 UTC
[GitHub] [airflow] uranusjr commented on a diff in pull request #34118: Refactor: Simplify string generation
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org