-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1044 get rid of all global variables and move to a config data class #1077
1044 get rid of all global variables and move to a config data class #1077
Conversation
This dataclass takes in filename and urls from the AUXILILARY section of the config file. If AUXILIARY section does not exist, default filenames and URLs are instead used.
changed function make_retriever use the config dataclass auxiliary. Went through the ephemeris files and updated this funtion. Completely removed all the global variables in similation_data_files.py.
…e-to-a-config-data-class
removed global variables being imported
The review needs to check sorcha bootstrap works so does sorcha run with the aux files already downloaded, and also sorcha run with the files needing to be downloaded. @Little-Ryugu has tested this locally |
@bernardinelli would you be able to test and see how we would test this on an order version of the files inputting in the config file? |
An example of the config file format for initialising a new file.
|
@@ -820,6 +1015,9 @@ class sorchaConfigs: | |||
expert: expertConfigs = None | |||
"""expertConfigs dataclass which stores the keywords from the EXPERT section of the config file.""" | |||
|
|||
auxiliary: auxiliaryConfigs = None | |||
"""auxiliaryConfigs dataclass which stores the keywords from the AUXILILARY section of the config file.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo AUXILILARY
:D
@@ -129,35 +125,42 @@ def parse_orbit_row(row, epochJD_TDB, ephem, sun_dict, gm_sun, gm_total): | |||
return tuple(np.concatenate([equatorial_coords, equatorial_velocities])) | |||
|
|||
|
|||
default = sorchaConfigs() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are now global variables because the are outside of any function. Can you have oc_file=None and if it's None then you create default? within class Obsevatory
@@ -129,35 +125,42 @@ def parse_orbit_row(row, epochJD_TDB, ephem, sun_dict, gm_sun, gm_total): | |||
return tuple(np.concatenate([equatorial_coords, equatorial_velocities])) | |||
|
|||
|
|||
default = sorchaConfigs() | |||
default.auxiliary = auxiliaryConfigs() # using the default observatory_codes in the auxiliaryConfigs class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are now global variables because the are outside of any function. Can you have oc_file=None and if it's None then you create default? within class Obsevatory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all of default or can you just make an
auxConfig = auxiliaryConfigs() and send that around. If we're not using any part of sconfigs other than auxConfig bits i'd just send that through
class Observatory: | ||
""" | ||
Class containing various utility tools related to the calculation of the observatory position | ||
""" | ||
|
||
def __init__(self, args, oc_file=OBSERVATORY_CODES): | ||
def __init__(self, args, sconfigs, oc_file=default.auxiliary.observatory_codes): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if sconfigs is None than you set oc_file- do you really need to set oc_file here with a global?
retriever = make_retriever(args.ar_data_file_path) | ||
planets_file_path = retriever.fetch(JPL_PLANETS) | ||
small_bodies_file_path = retriever.fetch(JPL_SMALL_BODIES) | ||
retriever = make_retriever(sconfigs, args.ar_data_file_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd consider only passing it the ephemeris config bits since we use this in bootstrap utility where we don't have a config file class loaded since it's doesn't read one in @bernardinelli what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that makes sense. One way to do this would be to have an independent class or dictionary or something has only the ephemeris stuff, so that it can also be created independently in bootstrap. Or if sconfigs
doesn't need to have everything set up, it'd accomplish the same thing (with no need to change the code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently I commented and did not finish the review so no one could see me comments. Thanks @Little-Ryugu for pointing that out. - there is a smaller ephemeris auxiliary file class instance that is made within the sconfigs class so we should just be able to pass the ephemeris auxiliary file class here
Changed make_retriever to only take aux config. Removed global variable in for class Observatory.
changed functions create_assist_ephemeris and furnish_spiceypy to only get the aux data class. Also added comment in bootstrap.py on how to download new files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me as intended
Fixes #1044
Fixes #1015
Created a new data class called auxiliaryConfigs. This data class contains the default filenames and URLs that Sorcha needs for ephemeris generation. These default filenames and URLs can be overwritten in the [AUXILIARY] section of the config file when running Sorcha. This data class replaces the global variables for these files.
Review Checklist for Source Code Changes