-
Notifications
You must be signed in to change notification settings - Fork 12
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
UI work #278
UI work #278
Conversation
Actually, just kidding about the merging, there is a better way to handle it. In any event, another bug needs to get fixed first. |
This makes it sort of act like a dict even though it is not.
@JuanCab -- the thing to focus on here is the new I'll get folks looking at the UI separately from getting this merged. |
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 I followed this in the end, but would appreciate answers to some of my questions. You need to fix all the mentions of passband_map
in the docstrings to indicate it is now a PassbandMap
object! Otherwise, while ugly, if it passes the tests, then we can say it works well enough.
autoui_widget_viewer.ipynb
Outdated
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.
Did note review notebook beyond GitHub changes interface, looks like mostly markdown changes anyway.
Creating an environment with `conda` or `mamba`: | ||
|
||
```bash | ||
mamba create -n stellarphot-test python=3.11 |
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.
So does stellarphot-test have all the dependencies defined? I have my own testing environment for stellarphot under conda and I should probably compare the two setups.
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.
No -- this section should be modified/removed. For testing of this branch I sent the instructions below. It creates a bare-bones environment then pip
installs everything from a github URL so people can try out the UI independent of whether we've done a pre-release or not and dodging all of the intricacies of git:
This first look will be to try out a couple of jupyter notebook-based forms for entering a bunch of settings.
I’d recommend, for now, that when you are testing you make a python environment for testing in, the delete the environment when you are done instead of trying to frequently update stellarphot. Instructions for doing that if you use conda are below, happy to provide non-conda instructions too.
To make an environment for testing called sp-test:
conda create -n sp-test python=3.11
When the environment is created, activate it:
conda ativaste sp-test
The command to install the version of stellarphot to try this time around is:
pip install git+https://github.com/mwcraig/stellarphot.git@ui-work
When this is done, please save the attached notebook to a folder, and navigate into that folder in the terminal. Run “jupyter lab
” to start up jupyter and try going through the notebook. After several cells of set up it will present forms for you to enter settings. Don’t worry about using realistic values for now.
I’m expecting you will have questions and that it needs more instructions, but figured getting a quick look sooner was better than waiting longer.
When you are done you can deactivate the environment and then remove it:
conda deactivate
conda remove --all --yes sp-test
stellarphot/core.py
Outdated
self._passband_map[orig_pb] if orig_pb in self._passband_map else orig_pb | ||
( | ||
self._passband_map[orig_pb] | ||
if orig_pb in self._passband_map.keys() |
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.
Isn't the default iterator for a dictionary keys? Oh, I see, you defined a method keys for the PassbandModel that returns the keys. Later I do see where you perform self._passband_map = passband_map.model_copy()
to set self._passband_map
... but passband_map
is a dict
according to the docstrings forCatalogData
and PhotometryData
. Does this need to get changed to PassbandMap
object?
Did you place this function the BaseEnhancedTable
so it is available to be inherited by CatalogData
and PhotometryData
? I ask because the passband mapping is not used in the BaseEnhancedTable
.
Finally, what is self["passband"]
? I can't find where self["passband"]
is even defined in BaseEnhancedTable
?
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.
Taking a look in a moment -- the intent was to have every place use a PassbandMap
object but to make that object act sort of like a dict.
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.
Also, you are write that the default iterator is over keys, but I wasn't sure which dunder method I needed to use to make that happen. Can dig it up in Fluent Python probably.
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.
Did you place this function the BaseEnhancedTable so it is available to be inherited by CatalogData and PhotometryData? I ask because the passband mapping is not used in the BaseEnhancedTable.
I think _update_passbands
has been in BaseEnhancedTable
for a while: https://github.com/feder-observatory/stellarphot/blob/main/stellarphot/core.py#L166
I do think you are correct about the reason it is in BaseEnhancedTable
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.
Finally, what is self["passband"]?
Took me a sec to remember, it is one of the columns in the table.
stellarphot/settings/models.py
Outdated
@@ -545,27 +564,81 @@ class PhotometryOptions(BaseModelWithTableRep): | |||
fwhm_by_fit: bool = True | |||
|
|||
|
|||
class PassbandMapEntry(BaseModel): | |||
""" | |||
long loing liong liong liong long long |
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.
What is this?
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.
oops, meant to edit that 😬 it was keyboard mashing.
"B": "B", | ||
"rp": "SR", | ||
} | ||
PASSBAND_MAP = PassbandMap( |
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.
So this is using the pydantic model... but stellarphot/core wasn't?
A dictionary containing instrumental passband names as keys and | ||
AAVSO passband names as values. This is used to rename the passband | ||
entries in the output photometry table. | ||
your_filter_names_to_aavso : list[`stellarphot.settings.PassbandMapEntry`] |
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.
OK, this makes sense, although again, not seeing how stellarphot/core.py
knows about this?
This also tests them and improves the documentation
@JuanCab -- I think this is ready for another look |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #278 +/- ##
==========================================
+ Coverage 70.09% 71.29% +1.19%
==========================================
Files 24 25 +1
Lines 3023 3100 +77
==========================================
+ Hits 2119 2210 +91
+ Misses 904 890 -14 ☔ View full report in Codecov by Sentry. |
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.
My only issue is in the docs of stellarphot/core.py
you refer to PassbandMap as a dictionary. I do think you have a point in that it certainly behaves like a dictionary, BUT it isn't created like dict
... don't know if that will confuse people who actually read the docstrings but are not familiar with pydantic.
stellarphot/core.py
Outdated
@@ -284,7 +285,7 @@ class PhotometryData(BaseEnhancedTable): | |||
names as values. This is used to automatically update the column | |||
names to the desired names before the validation is performed. | |||
|
|||
passband_map: dict, optional (Default: None) | |||
passband_map: `stellarphot.settings.PassbandMap`, optional (Default: None) | |||
A dictionary containing instrumental passband names as keys and |
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 you want to call it a dictionary
in the documentation? I guess It is a dictionary behaviorally, but it is not a dict
. For one thing, creating a PassbandMap
object requires a very different syntax.
What happens if the user reads the docstring and just passes in a dict
? It should fail (or convert?). Maybe we add an Exception that reports they passed in a dict
and tells them how to convert it into a proper PassbandMap
object?
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.
Oops, that was completely an oversight on my part. I'll change the wording here and below.
stellarphot/core.py
Outdated
@@ -603,7 +604,7 @@ class CatalogData(BaseEnhancedTable): | |||
names as values. This is used to automatically update the column | |||
names to the desired names BEFORE the validation is performed. | |||
|
|||
passband_map: dict, optional (Default: None) | |||
passband_map: `stellarphot.settings.PassbandMap`, optional (Default: None) | |||
A dictionary containing instrumental passband names as keys and |
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.
Same quibble with calling it a dictionary as above.
@@ -88,6 +88,10 @@ def test_target_file(): | |||
except ConnectionError: | |||
server_down = True | |||
tess_target = None # Assure tess_target is defined so that we can delete it | |||
except ValueError: | |||
# The server is teechnically back but producing garbage.... |
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.
"technically" not "teechnically"...
use_coordinates: Literal["sky", "pixel"] = "sky" | ||
shift_tolerance: NonNegativeFloat = 5.0 | ||
|
||
|
||
class PhotometryOptions(BaseModelWithTableRep): | ||
class PhotometryOptionalSettings(BaseModelWithTableRep): |
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 agree, better name.
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 like how you added support to make PassbandMap behave like a dict in many ways.
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.
That was partly bcc it was easier to do that than it was to rewrite code that used PassbandMap
🤣
@JuanCab -- made the changes you suggested. If test pass I think this can be merged/ |
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.
OK, looks good.
@JuanCab -- if this passes tests I'm going to merge it so we can have a couple folks try out some of the settings forms.