Skip to content

Refactor: Simplify string generation in providers#34221

Closed
eumiro wants to merge 1 commit intoapache:mainfrom
eumiro:string-generation-providers
Closed

Refactor: Simplify string generation in providers#34221
eumiro wants to merge 1 commit intoapache:mainfrom
eumiro:string-generation-providers

Conversation

@eumiro
Copy link
Contributor

@eumiro eumiro commented Sep 8, 2023

No description provided.

@boring-cyborg boring-cyborg bot added area:providers provider:amazon AWS/Amazon - related issues provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:elasticsearch provider:google Google (including GCP) related issues provider:microsoft-azure Azure-related issues provider:oracle labels Sep 8, 2023
@eumiro eumiro marked this pull request as ready for review September 8, 2023 19:27
Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

urlsplit and urlencode are great, but sometimes their result is unexpected. IMHO we need to add tests for these changes.

Comment on lines -169 to +172
path = path.replace("s3://", "")
split_path = path.split("/")
return Dataset(namespace=f"s3://{split_path[0]}", name="/".join(split_path[1:]), facets={})
split = urlsplit(path)
name = urlunsplit(split._replace(scheme="", netloc="")).lstrip("/")
return Dataset(namespace=f"{split.scheme}://{split.netloc}", name=name, facets={})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this kind of refactor is not safe, a unit test should be added to test it.

Comment on lines -127 to +128
extras_length = len(conn.extra_dejson)
if not extras_length:
return uri

uri += "?"

for arg_key, arg_value in conn.extra_dejson.items():
extras_length -= 1
uri += f"{arg_key}={arg_value}"

if extras_length:
uri += "&"
if conn.extra_dejson:
uri += "?" + parse.urlencode(conn.extra_dejson)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@eladkal
Copy link
Contributor

eladkal commented Oct 6, 2023

ping @eumiro can you address comments?

@eumiro eumiro closed this Oct 8, 2023
@eumiro eumiro deleted the string-generation-providers branch October 8, 2023 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:amazon AWS/Amazon - related issues provider:cncf-kubernetes Kubernetes (k8s) provider related issues provider:elasticsearch provider:google Google (including GCP) related issues provider:microsoft-azure Azure-related issues provider:oracle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments