Skip to content

Commit c944898

Browse files
Remove conditional code for Python versions less than 3.9 (#442)
This patch removes some conditional branches that were set up to support Python 3.8. Now that we have gotten rid of Python 3.8 support these can be removed. Fixes #38.
1 parent 45b5a3c commit c944898

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

compiler_opt/distributed/worker.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""Common abstraction for a worker contract."""
1616

1717
import abc
18-
import sys
1918
from typing import Any, List, Iterable, Optional, Protocol, TypeVar
2019

2120
import gin
@@ -104,8 +103,4 @@ def get_full_worker_args(worker_class: 'type[Worker]', **current_kwargs):
104103
# we don't have a way to check if `worker_class` is even known to gin, and
105104
# it's not a requirement that it were. Tests, for instance, don't use gin.
106105
pass
107-
# Issue #38
108-
if sys.version_info >= (3, 9):
109-
return current_kwargs | gin_config
110-
else:
111-
return {**current_kwargs, **gin_config}
106+
return current_kwargs | gin_config

compiler_opt/rl/data_collector_test.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""Tests for data_collector."""
1616

1717
# pylint: disable=protected-access
18-
import sys
1918
from unittest import mock
2019

2120
from absl.testing import absltest
@@ -29,11 +28,7 @@ def test_build_distribution_monitor(self):
2928
data = [3, 2, 1]
3029
monitor_dict = data_collector.build_distribution_monitor(data)
3130
reference_dict = {'mean': 2, 'p_0.1': 1}
32-
# Issue #38
33-
if sys.version_info >= (3, 9):
34-
self.assertEqual(monitor_dict, monitor_dict | reference_dict)
35-
else:
36-
self.assertEqual(monitor_dict, {**monitor_dict, **reference_dict})
31+
self.assertEqual(monitor_dict, monitor_dict | reference_dict)
3732

3833
@mock.patch('time.time')
3934
def test_early_exit(self, mock_time):

compiler_opt/rl/local_data_collector_test.py

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
# pylint: disable=protected-access
1818
import collections
1919
import string
20-
import sys
2120
from typing import List, Tuple
2221

2322
import tensorflow as tf
@@ -180,15 +179,8 @@ def _test_iterator_fn(data_list):
180179
'total_trajectory_length': 18,
181180
}
182181
}
183-
# Issue #38
184-
if sys.version_info >= (3, 9):
185-
self.assertEqual(monitor_dict,
186-
monitor_dict | expected_monitor_dict_subset)
187-
else:
188-
self.assertEqual(monitor_dict, {
189-
**monitor_dict,
190-
**expected_monitor_dict_subset
191-
})
182+
self.assertEqual(monitor_dict,
183+
monitor_dict | expected_monitor_dict_subset)
192184
data_iterator, monitor_dict = collector.collect_data(
193185
policy=_mock_policy, model_id=0)
194186
data = list(data_iterator)
@@ -200,15 +192,8 @@ def _test_iterator_fn(data_list):
200192
'total_trajectory_length': 18,
201193
}
202194
}
203-
# Issue #38
204-
if sys.version_info >= (3, 9):
205-
self.assertEqual(monitor_dict,
206-
monitor_dict | expected_monitor_dict_subset)
207-
else:
208-
self.assertEqual(monitor_dict, {
209-
**monitor_dict,
210-
**expected_monitor_dict_subset
211-
})
195+
self.assertEqual(monitor_dict,
196+
monitor_dict | expected_monitor_dict_subset)
212197

213198
collector.close_pool()
214199

0 commit comments

Comments
 (0)