Migrating from glue.datafind

This document provides some basic instructions on how to update code written to use glue.datafind to using gwdatafind.

Renamed objects

The table below summarise all renamings between glue.datafind and gwdatafind.

glue.datafind name gwdatafind name
GWDataFindHTTPConnection HTTPConnection
GWDataFindHTTPSConnection HTTPSConnection
GWDataFindHTTPConnection.find_frame HTTPConnection.find_url
GWDataFindHTTPConnection.find_frame_urls HTTPConnection.find_urls

Query output type

glue.datafind returns list of URLs as a glue.lal.Cache of lal.CacheEntry objects. gwdatafind returns simple lists of str. You can translate the new form back to the old easily:

from glue.lal import Cache
cache = Cache.from_urls(urls)

Creating a connection

glue.datafind provided no convenience methods for opening a new connection, so you probably wrote your own function that stripped the port number from the server name, and handled HTTP/HTTPS manually. With gwdatafind, you can just use the gwdatafind.connect() method to handle that:

>>> from gwdatafind import connect
>>> connection = connect()

or if you know the server URL:

>>> connection = connect('datafind.server.url:443')

Simplified single calls

If you are only interested in a single query to a single server (the typical use case), you can utilise one of the new top-level functions. So, instead of:

>>> from glue.datafind import GWDataFindHTTPConnection
>>> connection = GWDataFindHTTPConnection()
>>> cache = connection.find_frame_urls(...)

you can just use:

>>> from gwdatafind import find_urls
>>> urls = find_urls(...)

The arguments and syntax for find_urls() is the same as that of the old glue.datafind.GWDataFindHTTPConnection.find_frame_urls() method.

Similar top-level functions exist for ping(), find_observatories(), find_types(), find_times(), find_url(), find_latest(), and find_urls()

Command-line usage

The lscsoft-glue package provides the gw_data_find script, used to perform queries from the command-line. gwdatafind provides an identical interface via Python module execution (python -m).

To migrate, replace gw_data_find with python -m gwdatafind.