APS-4ID-POLAR / polartools

Python package to read and process data from the APS Polar beamline.
https://polartools.readthedocs.io/en/latest/
Other
2 stars 2 forks source link

Db tools #37

Closed strempfer closed 3 years ago

lgtm-com[bot] commented 3 years ago

This pull request introduces 7 alerts when merging 45c687f0d68f2656a2fb9d84a61c051dce38845d into 97907c2876efd541c6e6fcc7f4af2db00b900f34 - view on LGTM.com

new alerts:

gfabbris commented 3 years ago

@strempfer: I could work on this now, but just want to be sure that you're not in the middle of changing something, otherwis e the commits can get messed up.

codecov-io commented 3 years ago

Codecov Report

Merging #37 (15cdfd9) into main (97907c2) will decrease coverage by 9.93%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #37      +/-   ##
==========================================
- Coverage   55.95%   46.02%   -9.94%     
==========================================
  Files           6        8       +2     
  Lines         672      817     +145     
==========================================
  Hits          376      376              
- Misses        296      441     +145     
Impacted Files Coverage Δ
polartools/db_tools.py 0.00% <0.00%> (ø)
polartools/plotting.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 97907c2...15cdfd9. Read the comment docs.

gfabbris commented 3 years ago

I added a show_meta_2 in the last commit. The main aspect of it is that the metadata reading and printing are split (there is also a collect_meta). The idea is that, with collect_meta, it will strictly return the metadata you asked for, but show_meta will trim down things to look better.

I also used Pete's pyRestTable to print it:

In [6]: show_meta_2(10, db, scan_to=20, meta_keys='short')
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| Scan # | motors         | scan_type | plan_name | init. pos. | final pos. | num_points | exit_status |
+========+================+===========+===========+============+============+============+=============+
| 10     | magnet_6T_taby | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 11     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 12     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 13     | None           | None      | qxscan    | None       | None       | 128        | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 14     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 15     | None           | None      | qxscan    | None       | None       | 141        | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 16     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 17     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 18     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+
| 19     | magnet_6T_tabx | None      | rel_scan  | -0.2       | 0.2        | 40         | success     |
+--------+----------------+-----------+-----------+------------+------------+------------+-------------+

It has the advantage that it looks very nice. But it may create problems when the table gets too wide (although this may be problematic regardless).

gfabbris commented 3 years ago

One aspect of this is that our current metadata is not greatly consistent. For example, in the table printed above, the info in the "qxscan" is not very useful. We need to keep the metadata in mind when making plans...

lgtm-com[bot] commented 3 years ago

This pull request introduces 1 alert when merging bd7754992da9eb406d0103528ff8a818186da7fb into cf16d647bc8d25ea150e3f697f5dccd8c73210e0 - view on LGTM.com

new alerts:

lgtm-com[bot] commented 3 years ago

This pull request introduces 4 alerts when merging c2126028e3c1746d35c1085c1d4bd926b8ce1ecb into cf16d647bc8d25ea150e3f697f5dccd8c73210e0 - view on LGTM.com

new alerts:

gfabbris commented 3 years ago

@strempfer: Should we move db_query to db_tools?

strempfer commented 3 years ago

@strempfer: Should we move db_query to db_tools?

Since it only applied to dbs this would be good.

strempfer commented 3 years ago
  # TODO: I don't like this. We need better metadata.

Agree. I don't like this either. Just wanted to have something working. We should have metadata that are the same for all scans and scan types.