Skip to content

Update DataSourceInfo API

James Kennington requested to merge feature-datasource-api into master

Motivation

The datasource information utilities in gstlal.datasource were designed such that optparse command-line arg parsing was the primary means of initializing a GWDataSourceInfo object; a necessary step to build any pipeline using mkbasicsrc. The new api, via DataSourceInfo has several goals:

  1. Direct construction of datasources from Python literals
  2. Preserve compatibility with command-line args
  3. Provide convenience functions for constructing pipeline datasources directly in Python

Changes

This MR touches a lot of scripts, but should preserve existing functionality. The primary changes occur in a single module, gstlal.datasource, where the GWDataSourceInfo object and utilities have been deprecated in favor of the DataSourceInfo object and utilities. Feature-set is preserved but interface is improved, see examples below. Specific changes include:

  • New DataSourceInfo class with improved interface and backwards compat
  • Generalized command-line parsing utilities, such as datasource.parse_list_to_dict
  • New administrative utilities in gstlal.utilities.admin for:
    • Adding deprecation warnings to classes, functions, or methods
    • Adding copyright stubs to modules
  • Accompanying tests

Examples

Legacy: GWDataSourceInfo

args = [
'--data-source=frames',
'--frame-cache=/path/to/cache',
'--channel-name=H1=CHANNEL',
'--gps-start-time=1234567',
'--gps-end-time=1234568',
]
parser = optparse.OptionParser(description="test legacy mkbasicsrc")
datasource.append_options(parser)
options, filenames = parser.parse_args(args)
info = GWDataSourceInfo(options)

New api: DataSourceInfo

info = DataSourceInfo(data_source='frames',
                      frame_cache='path/to/cache',
                      gps_start_time=1234567,
                      gps_end_time=1234568,
                      channel_name={'H1': 'CHANNEL'})

Refactor and Drop-In Replacement

What was:

gw_data_source_info = datasource.GWDataSourceInfo(options)

Becomes:

gw_data_source_info = datasource.DataSourceInfo.from_optparse(options)
Edited by James Kennington

Merge request reports

Loading