Closed rossjjennings closed 6 months ago
OK, tests are passing locally now (you can't see them here because PR #62 hasn't been merged yet). The configuration variables live in pint_pal.config
, and the default values are loaded from defaults.yaml
. When pint_pal.set_data_root()
is called, it will look for a file in the provided directory called pint_pal_project.yaml
and load the corresponding settings from there (some can be omitted, and it will fall back on the default values).
A couple of somewhat weird things about this solution are:
from pint_pal.config import LATEST_BIPM
) and then expect them to change when you call pint_pal.set_data_root()
. Instead you should do import pint_pal.config
and use pint_pal.config.LATEST_BIPM
(from pint_pal import config
and config.LATEST_BIPM
) also works. I have changed existing places where they are used to do it this way.tim_directory
and par_directory
attributes of a TimingConfiguration
are now somewhat "magic": If you assign a relative path to them and then read them, you'll find that they contain the corresponding absolute path. I think this is mostly a good thing.Code looks good but would be helpful to test out more use cases (running from different directories, etc.). Ross said he'll wait til PR #63 is merged in.
Just tried running a notebook from outside the main directory with this -- it worked just fine! I've added a couple more things just for convenience. There is now a function reset_data_root()
that allows you to undo the effect of set_data_root()
, which I realized wasn't straightforward. And I've tweaked set_data_root()
and the TimingConfiguration
constructor to allow you to use ~
as an abbreviation for your home directory in paths.
There's now a related MR on the NG20 repository to add the pint_pal_project.yaml
file.
This addresses #57 and #58. I have added a "config" submodule, which replaces
defaults.py
for configuring things like the BIPM and JPL ephemeris versions used in checks. The intended use case is for data repositories like the NG20 repository to include a file calledpint_pal_project.yaml
in the root of the repository that specifies these settings, and then notebooks, etc., will callpint_pal.set_data_root()
, passing in the path to the root of the data repository. This will cause PINT Pal to read in thepint_pal_project.yaml
file, and also inform it of the path to the data repository so that it can be used in resolvingtim-directory
,par-directory
, and similar paths specified in the per-pulsar YAML files.