Skip to content

Commit 906a2f3

Browse files
committed
[code quality] Tread warnings as errors; track allow-listed warnings.
1 parent 846df06 commit 906a2f3

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

compiler_opt/rl/compilation_runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def get_command_line_for_bundle(
8080
ir_file: str,
8181
thinlto: Optional[str] = None,
8282
additional_flags: Tuple[str, ...] = (),
83-
delete_flags: Tuple[str, ...] = ()) -> List[str]:
83+
delete_flags: Tuple[str, ...] = ()
84+
) -> List[str]:
8485
"""Cleans up base command line.
8586
8687
Remove certain unnecessary flags, and add the .bc file to compile and, if

compiler_opt/rl/data_collector.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@
3838
def build_distribution_monitor(data: Sequence[float]) -> Dict[str, float]:
3939
if not data:
4040
return {}
41-
quantiles = np.percentile(
42-
data, REWARD_QUANTILE_MONITOR, interpolation='lower')
41+
quantiles = np.percentile(data, REWARD_QUANTILE_MONITOR, method='lower')
4342
monitor_dict = {
4443
f'p_{x}': y for (x, y) in zip(REWARD_QUANTILE_MONITOR, quantiles)
4544
}

compiler_opt/rl/data_collector_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class DataCollectorTest(absltest.TestCase):
2828
def test_build_distribution_monitor(self):
2929
data = [3, 2, 1]
3030
monitor_dict = data_collector.build_distribution_monitor(data)
31-
self.assertDictContainsSubset({'mean': 2, 'p_0.1': 1}, monitor_dict)
31+
self.assertEqual(monitor_dict, monitor_dict | {'mean': 2, 'p_0.1': 1})
3232

3333
@mock.patch('time.time')
3434
def test_early_exit(self, mock_time):

compiler_opt/rl/local_data_collector_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def _test_iterator_fn(data_list):
147147
'total_trajectory_length': 18,
148148
}
149149
}
150-
self.assertDictContainsSubset(expected_monitor_dict_subset, monitor_dict)
150+
self.assertEqual(monitor_dict, monitor_dict | expected_monitor_dict_subset)
151151

152152
data_iterator, monitor_dict = collector.collect_data(policy_path='policy')
153153
data = list(data_iterator)
@@ -158,7 +158,7 @@ def _test_iterator_fn(data_list):
158158
'total_trajectory_length': 18,
159159
}
160160
}
161-
self.assertDictContainsSubset(expected_monitor_dict_subset, monitor_dict)
161+
self.assertEqual(monitor_dict, monitor_dict | expected_monitor_dict_subset)
162162

163163
collector.close_pool()
164164

pytest.ini

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# DO always create a tracking issue when allow-listing warnings
2+
# DO NOT disable warnings-as-error: warnings of today are tomorrow's evolvability blocker.
3+
[pytest]
4+
filterwarnings =
5+
# Tread warnings as errors
6+
error
7+
8+
# ...except this allow list:
9+
# Issue #35
10+
ignore:the imp module is deprecated:DeprecationWarning
11+
12+
# Issue #36
13+
ignore:`np.bool` is a deprecated alias:DeprecationWarning
14+
15+
# Issue #37
16+
ignore:Encoding a StructuredValue with type tf_agents.policies.greedy_policy.DeterministicWithLogProb_ACTTypeSpec:UserWarning

0 commit comments

Comments
 (0)