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

Eliminate AbstractTaskTrialSpec #35

Closed
mlprt opened this issue Mar 10, 2024 · 1 comment
Closed

Eliminate AbstractTaskTrialSpec #35

mlprt opened this issue Mar 10, 2024 · 1 comment

Comments

@mlprt
Copy link
Owner

mlprt commented Mar 10, 2024

Currently, typing in feedbax.task is a mess. A source of this mess is AbstractTaskTrialSpec.

feedbax/feedbax/task.py

Lines 150 to 167 in 1c239e6

class AbstractTaskTrialSpec(Module):
"""Abstract base class for trial specifications provided by a task.
Attributes:
inits: A mapping from `lambdas` that select model substates to be
initialized, to substates to initialize them with.
inputs: A PyTree of inputs to the model.
target: A PyTree of target states.
intervene: A mapping from unique intervenor names, to per-trial
intervention parameters.
"""
inits: AbstractVar[WhereDict]
# inits: OrderedDict[Callable[[AbstractState], PyTree[Array]],
# PyTree[Array]]
inputs: AbstractVar[AbstractTaskInputs]
target: AbstractVar[PyTree[Array]]
intervene: AbstractVar[Mapping[str, Array]]

Once (#10) the target field is specified in a generalized way similarly to inits, the only field that will vary systematically between tasks will be inputs. In that case I suspect it will make more sense to eliminate subclassing of AbstractTaskTrialSpec, and instead define it as a generic final class, something like:

InputT = TypeVar("InputT", Module, Array)

class TaskTrialSpec(Module, Generic[InputsT]):
    inits: WhereDict
    inputs: InputsT
    targets: WhereDict
    intervene: Mapping[str, Array]

This would also save developers from explicitly including the intervene field in subclasses of AbstractTaskTrialSpec, because subclassing would be unnecessary; see #20.

I am still not sure how (if at all) to explicitly associate the structure of a given type of inputs, and the type of model that is compatible with a task. In principle, it could involve multiple fields of TaskTrialSpec; see #14.

@mlprt
Copy link
Owner Author

mlprt commented Apr 28, 2024

AbstractTaskTrialSpec has been replaced by TaskTrialSpec as of 4f735f4.

@mlprt mlprt closed this as completed Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant