MCPcopy Create free account
hub / github.com/Materials-Consortia/optimade-python-tools / get

Method get

optimade/client/client.py:302–356  ·  view source on GitHub ↗

Gets the results from the endpoint and filter across the defined OPTIMADE APIs. Parameters: filter: The OPTIMADE filter string for the query. endpoint: The endpoint to query. response_fields: A list of response fields to request fr

(
        self,
        filter: str | None = None,
        endpoint: str | None = None,
        response_fields: list[str] | None = None,
        sort: str | None = None,
    )

Source from the content-addressed store, hash-verified

300 return super().__getattribute__(name)
301
302 def get(
303 self,
304 filter: str | None = None,
305 endpoint: str | None = None,
306 response_fields: list[str] | None = None,
307 sort: str | None = None,
308 ) -> dict[str, dict[str, dict[str, dict]]]:
309 """Gets the results from the endpoint and filter across the
310 defined OPTIMADE APIs.
311
312 Parameters:
313 filter: The OPTIMADE filter string for the query.
314 endpoint: The endpoint to query.
315 response_fields: A list of response fields to request
316 from the server.
317 sort: The field by which to sort the results.
318
319 Raises:
320 RuntimeError: If the query could not be executed.
321
322 Returns:
323 A nested mapping from endpoint, filter and base URL to the query results.
324
325 """
326
327 if endpoint is None:
328 if self.__current_endpoint is not None:
329 endpoint = self.__current_endpoint
330 self.__current_endpoint = None
331 else:
332 endpoint = "structures"
333
334 if filter is None:
335 filter = ""
336
337 self._check_filter(filter, endpoint)
338
339 with self._progress:
340 if not self.silent:
341 self._progress.print(
342 Panel(
343 f"Performing query [bold yellow]{endpoint}[/bold yellow]/?filter=[bold magenta][i]{filter}[/i][/bold magenta]",
344 expand=False,
345 )
346 )
347 results = self._execute_queries(
348 filter,
349 endpoint,
350 response_fields=response_fields,
351 page_limit=None,
352 paginate=True,
353 sort=sort,
354 )
355 self.all_results[endpoint][filter] = results
356 return {endpoint: {filter: {k: results[k].asdict() for k in results}}}
357
358 def count(
359 self, filter: str | None = None, endpoint: str | None = None

Callers 15

_getFunction · 0.95
test_client_endpointsFunction · 0.95
test_filter_validationFunction · 0.95
test_multiple_base_urlsFunction · 0.95
test_client_sortFunction · 0.95
countMethod · 0.45
list_propertiesMethod · 0.45

Calls 4

_check_filterMethod · 0.95
_execute_queriesMethod · 0.95
printMethod · 0.80
asdictMethod · 0.80