Skip to content

Commit

Permalink
Remove conditional code for Python versions less than 3.9 (#442)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
boomanaiden154 authored Feb 13, 2025
1 parent 45b5a3c commit c944898
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 31 deletions.
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

0 comments on commit c944898

Please sign in to comment.