tiled icon indicating copy to clipboard operation
tiled copied to clipboard

In Python client, produce URIs to search results

Open danielballan opened this issue 2 years ago • 1 comments

A long-standing aim of Tiled is to provide URLs to arbitrary units of data. The URLs can be passed to curl or a data analysis program that speaks HTTP, shared with colleagues, associated with DOIs in publications, etc.

It would be nice if the Python client provided an easy way to obtain URLs that point to search results. We produce URLs to nodes, but not to their contents, filtered or otherwise:

In [14]: c['nmc_sim']
Out[14]: <Container {'22a5JHY7z5w', '22ACa4ELm3h', '22eMren2rdQ', ...} ~16467 entries>

In [15]: c['nmc_sim'].uri
Out[15]: 'https://aimm.lbl.gov/api/v1/metadata/nmc_sim'

In [16]: c['nmc_sim'].search(Key('sim_code') == 'fdmnes')
Out[16]: <Container {'22a5JHY7z5w', '22ACa4ELm3h', '22eMren2rdQ', ...} ~14740 entries>

In [17]: c['nmc_sim'].search(Key('sim_code') == 'fdmnes').uri
Out[17]: 'https://aimm.lbl.gov/api/v1/metadata/nmc_sim' <--- not what I wanted!

danielballan avatar Jan 05 '24 14:01 danielballan

It's worth pointing out that you can handle the URIs to from_uri which will "navigate" directly to that node:

from_uri('https://aimm.lbl.gov/api/v1/metadata/nmc_sim')

I think the task here, then, would be two-fold:

  1. Expose a contents_uri (name negotiable) that points to a /search/ endpoint, which may have filtering query parameters.
  2. Teach from_uri what to do with a /search/ URL.

danielballan avatar Jan 10 '24 14:01 danielballan