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

Decorator for extraction options from strategy file #179

Closed
tjgalvin opened this issue Oct 10, 2024 · 3 comments
Closed

Decorator for extraction options from strategy file #179

tjgalvin opened this issue Oct 10, 2024 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@tjgalvin
Copy link
Owner

When using a strategy file the general usage is something like:

# Get the options out of the file
wsclean_options = get_options_from_strategy(
    strategy=strategy, mode="wsclean", round=current_round
)
# Pass in the options to the wsclean function, note the update_wsclean_options
wsclean_cmds = task_wsclean_imager.map(
    in_ms=cal_mss,
    wsclean_container=field_options.wsclean_container,
    update_wsclean_options=unmapped(wsclean_options),
    fits_mask=fits_beam_masks,
)

It might be nice to add a decorator to the task_wsclean_imager function

@wrapper_options_from_strategy
def task_wsclean_imager(...):

so that we can do something like

wsclean_cmds = task_wsclean_imager.map(
    in_ms=cal_mss,
    wsclean_container=field_options.wsclean_container,
    update_wsclean_options=unmapped(wsclean_options),
    fits_mask=fits_beam_masks,
    strategy=strategy, 
    mode="wsclean", 
    round=current_round
)

The problem is that should this be used we would need to either:
1 - ensure that every such function we wrap has a consistent update_options parameter
2 - update the wrapper_options_from_strategy to accept the keyword to update. Something like:

def wrapper_options_from_strategy(keyword):
   def wrapper(fn):
        def _get_options_from_strategy(strategy, *args, mode="wsclean", round="iinitial", **kwargs):
            options = get_options_from_strategy(strategy, round, mode)
            kwargs[keyword] = options
            return fn(*args, **kwargs)
       return _get_options_from_strategy
   return wrapper

so that the keyword to update is a necessary parameter to supply when decorating

@wraooer_options_from_strategy(keyword="update_wsclean_options")
def task_wsclean_imager(...):
@tjgalvin tjgalvin added enhancement New feature or request help wanted Extra attention is needed labels Oct 10, 2024
@tjgalvin
Copy link
Owner Author

I am playing around with this under the stratdec branch.

Personally, I prefer option 2. I think being explicit here is perhaps better then being sneaky. It also means we can further specify the mode and operations aspects of the keywords.

@tjgalvin
Copy link
Owner Author

Being consider in #180 . Seems to be working well.

@tjgalvin
Copy link
Owner Author

Closed in #180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant