Skip to content

Preflight client callback to allow queries to be customised per provider #2188

Description

@ml-evs

cc @mehmetgiritli & @alex-belozerov

It would be nice to have a mechanism to adjust filters before sending them when using custom fields. As an example, when querying a structures endpoint for custom fields e.g. band_gap, we would like to be able to control how that field gets mapped depending on the database being queried. In the simplest case, if someone asks to filter band_gap, then each database-specific prefix can be added so that COD recieves a query for _cod_band_gap, MP receives _mp_band_gap and so on. This avoids the user needing to construct some contorted query for _cod_band_gap > 0 OR _mp_band_gap > 0 for an indeterminate number of prefixes.

This could be straightforwardly implemented by parsing the filter and checking whether fields exist within the standard, then simply prefixing them if not.

In the more general case, it would also be very helpful to perform arbitrary mapping of field names programmatically, which could e.g., map bandgap to _cod_band_gap (note the field name is not the same), and potentially even map input values to reflect differing unit definitions. This could either be via some kind of local mapping or just by allowing general preflight callbacks that can define arbitrary logic (similar to the response callbacks we allow now).

I'm not sure if this is exactly we had in mind in discussions, so please do give your thoughts! This would be a very useful feature, so I'd be happy to help, but if you want it sooner rather than later it might be wise if someone took the lead on developing it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clientIssues/PRs relating to the OPTIMADE client.suggestions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions