Skip to content
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

Merged
merged 19 commits into from
Feb 29, 2024
Merged

UI work #278

merged 19 commits into from
Feb 29, 2024

Conversation

mwcraig
Copy link
Contributor

@mwcraig mwcraig commented Feb 23, 2024

@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.

@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 23, 2024

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.
@mwcraig mwcraig requested a review from JuanCab February 26, 2024 19:29
@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 26, 2024

@JuanCab -- the thing to focus on here is the new PassbandMap model. The old one (a stright-up dict) didn't have an automatically generate-able UI. The new one does. On the other hand, the new is a PITA to work with, so I made it settable from a dict, and added just enough methods to make it behave like a dict. Not at all sure this is the best way to go, but we can always change it later I suppose.

I'll get folks looking at the UI separately from getting this merged.

Copy link
Contributor

@JuanCab JuanCab left a 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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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

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()
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

@@ -545,27 +564,81 @@ class PhotometryOptions(BaseModelWithTableRep):
fwhm_by_fit: bool = True


class PassbandMapEntry(BaseModel):
"""
long loing liong liong liong long long
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this?

Copy link
Contributor Author

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.

stellarphot/core.py Show resolved Hide resolved
"B": "B",
"rp": "SR",
}
PASSBAND_MAP = PassbandMap(
Copy link
Contributor

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`]
Copy link
Contributor

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?

stellarphot/settings/models.py Show resolved Hide resolved
@mwcraig mwcraig requested a review from JuanCab February 27, 2024 17:47
@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 27, 2024

@JuanCab -- I think this is ready for another look

@codecov-commenter
Copy link

codecov-commenter commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.29%. Comparing base (85c37b1) to head (4dabd8d).
Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@JuanCab JuanCab left a 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.

@@ -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
Copy link
Contributor

@JuanCab JuanCab Feb 29, 2024

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?

Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor

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....
Copy link
Contributor

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):
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, better name.

Copy link
Contributor

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.

Copy link
Contributor Author

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 🤣

@mwcraig
Copy link
Contributor Author

mwcraig commented Feb 29, 2024

@JuanCab -- made the changes you suggested. If test pass I think this can be merged/

@JuanCab JuanCab self-requested a review February 29, 2024 17:01
Copy link
Contributor

@JuanCab JuanCab left a comment

Choose a reason for hiding this comment

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

OK, looks good.

@mwcraig mwcraig merged commit 43b121f into feder-observatory:main Feb 29, 2024
9 checks passed
@mwcraig mwcraig deleted the ui-work branch April 29, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants