Skip to content

Commit

Permalink
_load optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaume committed Nov 23, 2023
1 parent ecb2a28 commit d939526
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mpcontribs-client/mpcontribs/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,16 +680,15 @@ def _load(protocol, host, headers_json, project, version):
del config[key]
config["bravado"] = bravado_config
swagger_spec = Spec.from_dict(spec_dict, origin_url, http_client, config)
http_client.session.close()

if not spec_dict["paths"]:
return swagger_spec

# expand regex-based query parameters for `data` columns
query = {"name": project} if project else {}
query["_fields"] = ["columns"]
kwargs = dict(headers=headers, params=query)
resp = requests.get(f"{url}/projects/", **kwargs).json()
resp = http_client.session.get(f"{url}/projects/", params=query).json()
http_client.session.close()

if not resp or not resp["data"]:
raise MPContribsClientError(f"Failed to load projects for query {query}!")
Expand Down Expand Up @@ -721,9 +720,12 @@ def _load(protocol, host, headers_json, project, version):

for column in columns[key]:
param_name = f"{column}__{op}"
param_spec = deepcopy(param.param_spec)
param_spec = {
k: v
for k, v in param.param_spec.items()
if k != "description"
}
param_spec["name"] = param_name
param_spec.pop("description", None)
operation.params[param_name] = Param(
swagger_spec, operation, param_spec
)
Expand Down

0 comments on commit d939526

Please sign in to comment.