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

[POC] Decouple Task enums from task classes #175

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft

Conversation

matteobettini
Copy link
Collaborator

@matteobettini matteobettini commented Feb 11, 2025

Here is the concept.

Tasks are enum like before, but now they are decoupled from their class.

This is similar to the way that ModelConfig-> Model works (one class for config and one class for component)
(same for algos)

Now this is the case also for tasks: you have an enum that holds the config and you can call get_task() to lock the config into a task class.

task1 = VmasTask.BALANCE.get_from_yaml() # Get from yaml automatically converts to TaskClass
task2 = VmasTask.BALANCE.get_from_yaml() # Get from yaml automatically converts to TaskClass
task1.config.update({"a": 1})
task2.config.update({"a": 2})
assert task1.config["a"] == 1
assert task2.config["a"] == 2

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Feb 11, 2025
@matteobettini matteobettini marked this pull request as draft February 11, 2025 15:22
@matteobettini matteobettini changed the title [POC] Decouple Tas enums from task classes [POC] Decouple Task enums from task classes Feb 11, 2025
return self.update_config(config)
return self.get_task(config=config)

def supports_continuous_actions(self) -> bool:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should these two functions be here? wouldnt it be possible for the config of a task to modify whether or not it supports a discrete action?

return obj

def __init__(self, config: Dict[str, Any]):
class TaskClass(abc.ABC):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could add doc along the lines of:

Represents a specific environment that is to be constructed. 

The environment is fully defined by its constructor (TaskClass.get_env_fun) and its parameterization (TaskClass.config). 

Note that there could be a many-to-one mapping between TaskClasses and environments. For example: 
- A single TaskClass may allow construction of all environments of `PettingZoo`
- A single TaskClass may allow construction of environments of `PettingZoo` that only have discrete actions
- A single TaskClass may allow construction of just a specific `PettingZoo` environment. 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants