Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Python: omission of Optional field leads to Attribute Error in validate_conditions #2185

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

Closed
RonAtCFX opened this issue Jun 12, 2023 · 9 comments

Comments

@RonAtCFX
Copy link
Contributor

RonAtCFX commented Jun 12, 2023

Hi,

I'm testing the recently released python libs, version dev.50

In a PriceQuantity, the attribute "observable" is optional.

image

so I created a PriceQuantity, without an "observable":

image

when calling the validate_conditions() on the PriceQuantity, python raises a AttributeError:

image

this is on this test instruction:

image

Is this something erroneous on my side, or is the generated python code incorrect of incomplete?

@RonAtCFX
Copy link
Contributor Author

@dschwartznyc @minesh-s-patel

I've discussed this with @chrisisla and he suggested to raise an issue, and highlight this with you.

Can you please have a look at it, and revert? If you need any more information, just let me know.

Many thanks!
Ron

@RonAtCFX
Copy link
Contributor Author

PS: if I just add an empty observation, the validation works OK:

image

But I don't think it is a good idea to add empty attribute(s) just to get it validated?

@dschwartznyc
Copy link
Contributor

dschwartznyc commented Jun 12, 2023

One might argue that the Python function is behaving as expected since the definition of the condition makes reference to an attribute of an optional field rather than checking whether that field is defined first. The Rosetta definition of the condition is:

`condition RateOptionObservable: ...

    if observable -> rateOption exists and price exists
    then 
		price -> priceExpression -> priceType contains PriceTypeEnum -> InterestRate or
		price-> priceExpression -> priceType contains PriceTypeEnum -> MultiplierOfIndexValue`

The condition should have tested for the existence of observable first. IE

if observable exists and observable -> rateOption exists and price exists

It is possible for the generator to compensate but a stronger solution would be more rigorous checking of the Rosetta.

@RonAtCFX
Copy link
Contributor Author

@dschwartznyc @SimonCockx

How do we proceed with this? I don't think that someone should amend these conditions on a case per case basis, but changing them all at once is a massive change, which requires thorough analysis, execution and testing.

Please advice.

@SimonCockx
Copy link
Contributor

Hi @RonAtCFX

We've discussed this and came to the conclusion that the Python code generator should implement the same semantics as the Java code generator. In this case, that means that the Python code for the path operator -> should be able to handle arguments of optional or multiple cardinality instead of throwing an AttributeError. I've just raised an issue in the code generators repository to track this.

@RonAtCFX
Copy link
Contributor Author

@SimonCockx
many thanks for your prompt response. any planning when this will be delivered?

@dschwartznyc
Copy link
Contributor

dschwartznyc commented Jun 20, 2023 via email

@eteridvalishvili
Copy link
Contributor

Hi @RonAtCFX I hope this message finds you well! I'm following up on your question and wanted to check if it's okay to close now and if you've received your answer. If you haven’t and want to keep it open please let me know.

If you're interested in joining the Contribution Review Working Group (CRWG) meetings, we have sessions scheduled for tomorrow, February 6th at 10 am EST/3 pm GMT, and another on February 20th at the same time and we can discuss your questions directly with the maintainers. Please let me know your preferences or if you have any further questions or concerns. Looking forward to hearing from you!

@eteridvalishvili eteridvalishvili moved this to Open Questions in CDM CRWG Feb 6, 2024
@eteridvalishvili
Copy link
Contributor

Hi @RonAtCFX Closing this issue out because it has been open for more than 30 days with no activity. Please reopen if necessary and feel free to reach out to the CDM team if you have any questions.

@eteridvalishvili eteridvalishvili moved this from Open Questions to Closed in CDM CRWG Mar 18, 2024
@lolabeis lolabeis removed the question label Feb 13, 2025
@finos finos locked and limited conversation to collaborators Feb 13, 2025
@lolabeis lolabeis converted this issue into discussion #3414 Feb 13, 2025

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants