Skip to content

Conversation

@GaneevRizvan
Copy link
Collaborator

No description provided.

@hombit hombit self-requested a review November 10, 2025 14:48
Copy link
Member

@hombit hombit left a comment

Choose a reason for hiding this comment

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

Pre-approve it so deployment would run

Copy link
Member

Choose a reason for hiding this comment

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

Could you please update this file from the master branch?



class ModelFit:
base_url = "http://host.docker.internal:8000/api/v1"
Copy link
Member

Choose a reason for hiding this comment

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

This should be a configurable URL

],
"ebv": ebv,
"name_model": fit_model,
"redshift": [0.05, 0.3],
Copy link
Member

Choose a reason for hiding this comment

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

Sounds too arbitrary, should be at least class-level attribute, at most a parameter.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added Target class

json={
"parameters": params,
"name_model": name_model,
"zp": 8.9,
Copy link
Member

Choose a reason for hiding this comment

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

We have ABZPMAG_JY for that

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it

return params

def get_curve(self, df, dr, ref_mag_values, bright, params, name_model):
path = "/sncosmo/get_curve"
Copy link
Member

Choose a reason for hiding this comment

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

Should be a class/object attribute

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added a path in ModelFit and a function to set it.

self._api_session = requests.Session()

def fit(self, df, fit_model, ref_mag_values, dr, ebv):
path = "/sncosmo/fit"
Copy link
Member

Choose a reason for hiding this comment

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

Should be a class/object attribute

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it

Comment on lines 19 to 21
if not ref_mag_values:
oid_ref = {}
try:
Copy link
Member

Choose a reason for hiding this comment

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

I don't really understand this part of the code.

  1. What ref_mag_values supposed to be? True/False? Or None/dict? If the least, than you never use that dict, and also please change the statement to more explicit: if ref_mag_values is not None.
  2. If the catalog not available, you pass and never use the references. It is not a good behavior, because the result will change without user's consent, and do it implicitly without any notification. Maybe it is better to just fail, than do that
  3. You are mutating the input dataframe. It is not a good practice, what if the caller would reuse it? Please do something like df = df.copy() if you want to change the values.

Copy link
Collaborator Author

@GaneevRizvan GaneevRizvan Nov 30, 2025

Choose a reason for hiding this comment

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

I removed ref_mag_values and took into account the unavailability of getting a ref, and now I'm not changing the input dataframe.

]
except (NotFound, CatalogUnavailable):
pass
res_fit = requests.post(
Copy link
Member

Choose a reason for hiding this comment

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

What is the expected behavior if it fails? I think we normally catch it and raise a CatalogUnavailable error, which can be processed in the UI code.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I took into account the unavailability of getting a ref

else:
raise ValueError(f"{lc_type = } is unknown")
if name_model and fit_params:
df_fit = model_fit.get_curve(df, dr, ref_mag_values, bright, json.loads(fit_params), name_model)
Copy link
Member

Choose a reason for hiding this comment

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

What if it fails? We would lose the whole plot I guess...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed it

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.

2 participants