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

Remove conditional code for Python versions less than 3.9 #442

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions compiler_opt/distributed/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Common abstraction for a worker contract."""

import abc
import sys
from typing import Any, List, Iterable, Optional, Protocol, TypeVar

import gin
Expand Down Expand Up @@ -104,8 +103,4 @@ def get_full_worker_args(worker_class: 'type[Worker]', **current_kwargs):
# we don't have a way to check if `worker_class` is even known to gin, and
# it's not a requirement that it were. Tests, for instance, don't use gin.
pass
# Issue #38
if sys.version_info >= (3, 9):
return current_kwargs | gin_config
else:
return {**current_kwargs, **gin_config}
return current_kwargs | gin_config
7 changes: 1 addition & 6 deletions compiler_opt/rl/data_collector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""Tests for data_collector."""

# pylint: disable=protected-access
import sys
from unittest import mock

from absl.testing import absltest
Expand All @@ -29,11 +28,7 @@ def test_build_distribution_monitor(self):
data = [3, 2, 1]
monitor_dict = data_collector.build_distribution_monitor(data)
reference_dict = {'mean': 2, 'p_0.1': 1}
# Issue #38
if sys.version_info >= (3, 9):
self.assertEqual(monitor_dict, monitor_dict | reference_dict)
else:
self.assertEqual(monitor_dict, {**monitor_dict, **reference_dict})
self.assertEqual(monitor_dict, monitor_dict | reference_dict)

@mock.patch('time.time')
def test_early_exit(self, mock_time):
Expand Down
23 changes: 4 additions & 19 deletions compiler_opt/rl/local_data_collector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
# pylint: disable=protected-access
import collections
import string
import sys
from typing import List, Tuple

import tensorflow as tf
Expand Down Expand Up @@ -180,15 +179,8 @@ def _test_iterator_fn(data_list):
'total_trajectory_length': 18,
}
}
# Issue #38
if sys.version_info >= (3, 9):
self.assertEqual(monitor_dict,
monitor_dict | expected_monitor_dict_subset)
else:
self.assertEqual(monitor_dict, {
**monitor_dict,
**expected_monitor_dict_subset
})
self.assertEqual(monitor_dict,
monitor_dict | expected_monitor_dict_subset)
data_iterator, monitor_dict = collector.collect_data(
policy=_mock_policy, model_id=0)
data = list(data_iterator)
Expand All @@ -200,15 +192,8 @@ def _test_iterator_fn(data_list):
'total_trajectory_length': 18,
}
}
# Issue #38
if sys.version_info >= (3, 9):
self.assertEqual(monitor_dict,
monitor_dict | expected_monitor_dict_subset)
else:
self.assertEqual(monitor_dict, {
**monitor_dict,
**expected_monitor_dict_subset
})
self.assertEqual(monitor_dict,
monitor_dict | expected_monitor_dict_subset)

collector.close_pool()

Expand Down