Skip to content

65 refactor esams encoder decoder#68

Open
omereliy wants to merge 5 commits intomainfrom
65-refactor-esams-encoder-decoder
Open

65 refactor esams encoder decoder#68
omereliy wants to merge 5 commits intomainfrom
65-refactor-esams-encoder-decoder

Conversation

@omereliy
Copy link
Collaborator

implemented encoder-decoder methods for easmm and added tests to esam test file

omereliy added 4 commits March 5, 2025 09:51
- fixed bugs and refactored encoder and decoder related methods.
…ed action instances.

the encoder\decoder method are outside and testable fucntions (i.e. see esam_learning_tests).
@omereliy omereliy linked an issue Mar 12, 2025 that may be closed by this pull request
@omereliy omereliy linked an issue Mar 16, 2025 that may be closed by this pull request
@argaman-aloni argaman-aloni added the code-maintenance Things that were not well maintained and need to be revised label Mar 16, 2025
@argaman-aloni argaman-aloni self-requested a review March 16, 2025 20:25
Copy link
Owner

Choose a reason for hiding this comment

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

remove PLZ :)

proxy_action_call: grounded action call of the learned domain
new_proxy: the lifted instance of the grounded action call
proxy_data: data of the construction of the proxy actions
action_name: the original action's name.
Copy link
Owner

Choose a reason for hiding this comment

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

Isn't this also part of the proxy action data object? and if not, why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

they are not a part of the data.
"action_name" is the original action name and is not needed except for the encoder decoder methods since it appears in the outer scope of the call.
it is taken as an argument in order to bind those parameter when called inside a loop to the lambda arguments (though they can be explicitly bounded if called as an argument inside the lambda. i prefered this option).

the "new_proxy" can be saved inside the data

"proxy_action_call" is different at every call for for the method so it is an unbounded argument that is bounded only when encoder\decoder is needed.

"""
original_lifted_action = self.partial_domain.actions[action_name] if action_name in self.partial_domain.actions\
else self.popped_actions_archive[action_name]
original_signature = list(original_lifted_action.signature.keys())
Copy link
Owner

Choose a reason for hiding this comment

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

inline the usage (only single usage, so no need for additional variable)

original_lifted_action = self.partial_domain.actions[action_name] if action_name in self.partial_domain.actions\
else self.popped_actions_archive[action_name]
original_signature = list(original_lifted_action.signature.keys())
proxy_param_list = list(new_proxy.signature.keys())
Copy link
Owner

Choose a reason for hiding this comment

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

inline this as well

Copy link
Owner

Choose a reason for hiding this comment

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

inline this as well, just use the .items() where you need it.


new_obj_list = [original_action_map[param] for param in original_signature]
return ActionCall(action_name, new_obj_list)
def encoder_method(self, original_action_call: ActionCall, proxy_data: ProxyActionData, new_proxy: LearnerAction,
Copy link
Owner

Choose a reason for hiding this comment

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

add new line

raise NotSafeActionError(name=f"{new_proxy.name}",
reason="proxy action parameter mapping"
"does not align with the action call",
solution_type=EquationSolutionType.no_solution_found)
Copy link
Owner

Choose a reason for hiding this comment

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

This error type is not well fitted for what you want to do here... And notice that if you raise an error and not catch it later the entire program will stop. Is this what you want?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no. what error is appropriate for this case?

Copy link
Owner

Choose a reason for hiding this comment

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

don't forget the type annotation.

),
]
)
def test_decoder_full_example(rovers_esam_learner, rovers_esam_observation, proxy_action_call: ActionCall,
Copy link
Owner

Choose a reason for hiding this comment

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

I personally don't like the parameterization option if the outcome of the test indicates different behaviour since the behaviour is not explained (usually the test name gives indication on what you expect...)
I would like you to explain better when you test here, this does not mean you have to do much, just split this to tests and give indicative names to the test cases. OR you can keep the current format with the parameterization but give full indicative name to the test case, AND improve the documentation :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

okay i will' iin the meantime ill the changes and handle it later on today

for param_name, obj in original_param_mapping.items()}
for param_name, obj in original_param_mapping.items():
if grounded_proxy_parameters[proxy_data.signature[param_name]] != obj:
raise NotSafeActionError(name=f"{new_proxy.name}",
Copy link
Owner

Choose a reason for hiding this comment

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

Be careful, think about who will call this method and whether the error is being cought.

@argaman-aloni argaman-aloni moved this to In progress in SAM framework - workplan Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-maintenance Things that were not well maintained and need to be revised

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

test - esam's encoder decoder refactor esam's encoder-decoder

2 participants

Comments