Skip to content

FIREFLY-2076: Fix period in IDs causing problems for several methods - #81

Open
jaladh-singhal wants to merge 1 commit into
masterfrom
FIREFLY-2076-period-in-id-bug
Open

jaladh-singhal wants to merge 1 commit into
masterfrom
FIREFLY-2076-period-in-id-bug

Conversation

@jaladh-singhal

Copy link
Copy Markdown
Member

Fixes FIREFLY-2076

A period (.) in a tbl_id passed to show_table() caused the table's chart and coverage image not to display. The cause is in Firefly's JS code: some reducers use IDs as lodash string paths (lodash set/get treat a dot as a nesting separator), so my.table gets stored under my → table instead of as one key. Rather than fixing every such call in Firefly, the python client now rejects these IDs early with a clear error.

  • Added validate_id() in fc_utils.py, which raises a ValueError if an ID contains a period (suggesting _ instead)
  • Called it in every method that takes a user-supplied ID that Firefly code uses as a string path:
    • tbl_id: show_table, fetch_table (the table's default chart ID is 'default-' + tbl_id, which is why the chart disappeared)
    • chartId: show_chart (ChartsCntlr.js)
    • plot_id: show_fits_image/show_fits, show_fits_3color, show_hips, show_image_or_hips (RegionPlot.js, ImageLineBasedFootprint.js: region/footprint layers on the plot can break)
  • Noted the restriction in each affected parameter's docstring

Other IDs (viewer_id, group_id, cell_id, region_layer_id, mask_id, extension IDs) are only used as array paths or plain keys in Firefly, so they're safe.

Testing

Install Python package from this branch:

pip install git+https://github.com/Caltech-IPAC/firefly_client@FIREFLY-2076-period-in-id-bug
  1. Run examples/reference-guide.ipynb and change any tbl_id or plot_id to contain a period (e.g. cutout_image_plot_id = 'wise.cutout'). That cell should raise ValueError: plot_id 'wise.cutout' must not contain a period ('.'); use another character such as '_' instead, without sending anything to Firefly.
  2. Revert the ID to use _ or -. The notebook should run as before, with tables showing their default chart and coverage image.

@stargaser stargaser left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes work. I was only having trouble with tbl_ids originally, not with plot_ids. If plot_ids with periods don't cause problems, can we have them? In my scripts I use filenames like ztf_20171101229433_907017_zr_c16_o_q3_sciimg_ra338.9963_dec33.9586_asec600.fits so with this PR I'll have to change those all to underscores.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants