Skip to content

Commit a35da89

Browse files
generatedunixname893464919433493facebook-github-bot
authored andcommitted
Fix Pyre missing annotations in test_disjoint_bandit_container.py
Summary: ## Instructions about RACER Diffs: **Commandeer this diff (recommended) or land with accept2ship tag.** *This feature is still in BETA and we are continuously improving it. Your constructive feedback would help improving RACER and highly appreciated.* This diff was pre-created by Racer AI agent for your convenience on top of T235393804. How-to-code instruction is provided by oncall [Zhijia Zhang](https://www.internalfb.com/profile/view/405511865743720). For questions or suggestions please post in [RACER Maintainer](https://fb.workplace.com/groups/742040101615185) group. You will receive **FULL CREDIT** (ETS) for this diff if you either: - [**Recommended**]Commandeer and land this diff after another reviewer's approval - Accept it and ship it after required approvals are provided. Once landed, feel free to claim the associated task and the EYS project. This diff fixes pyre-missing-annotations warnings identified by Quality Insight from [Monetization codehub](https://fburl.com/quality/0kw8oby2) - If you are happy with the changes, commandeer it if minor edits are needed. (**we encourage commandeer to get the diff credit**) - If you are not happy with the changes, please comment on the diff with clear actions and send it back to the author. Racer will pick it up and re-generate. - If you really feel the Racer is not helping with this change (alas, some complex changes are hard for AI) feel free to abandon this diff. - **For M10N reviewers:** as you review AI-generated diffs, we ask you to give them the same priority as human-generated diffs, and take action in a timely manner by either accepting, rejecting, or resigning as a reviewer. For diffs that don't meet the quality bar (e.g. code doesn't compile, not readable or introduces functionality regressions), we ask that you use the following hashtags to provide clear signals to improve our tools - `#monlowqualitydiff` `#monwrongreviewerdiff` ## Summary: Fixed pyre-missing-annotations warnings in `fbcode/pearl/test/unit/with_pytorch/test_disjoint_bandit_container.py` by adding type annotations to the `PolicyLearnerWrapper` class methods: 1. Added `DisjointBanditContainer` and `ActionSpace` type annotations to the `__init__` method parameters and `-> None` return type 2. Added `torch.Tensor` type annotation to the `forward` method parameter and `-> Action` return type 3. Added necessary imports for `Action` and `ActionSpace` types The changes are minimal and only add the missing type annotations without modifying any functionality or logic. --- > Generated by [RACER](https://www.internalfb.com/wiki/RACER_(Risk-Aware_Code_Editing_and_Refactoring)/), powered by [Confucius](https://www.internalfb.com/wiki/Confucius/Analect/Shared_Analects/Confucius_Code_Assist_(CCA)/) [Session](https://www.internalfb.com/confucius?session_id=310414de-9208-11f0-a075-37b88107939a&tab=Chat), [Trace](https://www.internalfb.com/confucius?session_id=310414de-9208-11f0-a075-37b88107939a&tab=Trace) Differential Revision: D82289854 fbshipit-source-id: 3eea08caedee6e41003f36ba1f0e3994d01f38c3
1 parent 176c41c commit a35da89

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

test/unit/with_pytorch/test_disjoint_bandit_container.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import torch.jit
1515
import torch.testing as tt
1616
from parameterized import parameterized_class
17+
from pearl.api.action import Action
18+
from pearl.api.action_space import ActionSpace
1719
from pearl.policy_learners.contextual_bandits.disjoint_bandit import (
1820
DisjointBanditContainer,
1921
)
@@ -294,12 +296,14 @@ def test_traced_disjoint_bandit_container(self) -> None:
294296

295297
# Define a wrapper function for tracing that handles the act method
296298
class PolicyLearnerWrapper(torch.nn.Module):
297-
def __init__(self, policy_learner, action_space):
299+
def __init__(
300+
self, policy_learner: DisjointBanditContainer, action_space: ActionSpace
301+
) -> None:
298302
super().__init__()
299303
self.policy_learner = policy_learner
300304
self.action_space = action_space
301305

302-
def forward(self, state):
306+
def forward(self, state: torch.Tensor) -> Action:
303307
return self.policy_learner.act(
304308
subjective_state=state, available_action_space=self.action_space
305309
)

0 commit comments

Comments
 (0)