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

Dependency cleanup #666

Merged
merged 2 commits into from
Jun 4, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
13 changes: 2 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,10 @@ def run(self):
f.write('\n__version__ = "{}"\n'.format(version_git))

requirements = [
'six',
'numpy',
'protobuf >= 3.8.0',
'protobuf >= 3.8.0, <=3.20.1',
]

test_requirements = [
'future'
'pytest',
'matplotlib',
'crc32c',
]

setup(
name='tensorboardX',
Expand All @@ -74,16 +67,14 @@ def run(self):
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
],
cmdclass={
'develop': PostDevelopCommand,
'install': PostInstallCommand,
},
test_suite='tests',
tests_require=test_requirements
)


Expand Down
3 changes: 1 addition & 2 deletions tensorboardX/caffe2_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging
import os
import re
import six

from builtins import bytes
from caffe2.proto import caffe2_pb2
Expand Down Expand Up @@ -166,7 +165,7 @@ def _remap_keys(old_dict, rename_fn):
None. Modifies old_dict in-place.
'''
new_dict = {rename_fn(key): value for key,
value in six.iteritems(old_dict)}
value in old_dict.items()}
old_dict.clear()
old_dict.update(new_dict)

Expand Down
4 changes: 2 additions & 2 deletions tensorboardX/event_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import threading
import time
import multiprocessing
import six
import queue

from .proto import event_pb2
from .record_writer import RecordWriter, directory_check
Expand Down Expand Up @@ -207,7 +207,7 @@ def run(self):
return
self._record_writer.write_event(data)
self._has_pending_data = True
except six.moves.queue.Empty:
except queue.Empty:
pass

now = time.time()
Expand Down
4 changes: 1 addition & 3 deletions tensorboardX/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import re as _re

# pylint: disable=unused-import
from six.moves import range

from .proto.summary_pb2 import Summary
from .proto.summary_pb2 import HistogramProto
Expand Down Expand Up @@ -70,7 +69,6 @@ def _draw_single_box(image, xmin, ymin, xmax, ymax, display_str, color='black',
def hparams(hparam_dict=None, metric_dict=None):
from tensorboardX.proto.plugin_hparams_pb2 import HParamsPluginData, SessionEndInfo, SessionStartInfo
from tensorboardX.proto.api_pb2 import Experiment, HParamInfo, MetricInfo, MetricName, Status, DataType
from six import string_types

PLUGIN_NAME = 'hparams'
PLUGIN_DATA_VERSION = 0
Expand All @@ -91,7 +89,7 @@ def hparams(hparam_dict=None, metric_dict=None):
if v is None:
continue

if isinstance(v, string_types):
if isinstance(v, str):
ssi.hparams[k].string_value = v
hps.append(HParamInfo(name=k, type=DataType.Value("DATA_TYPE_STRING")))
continue
Expand Down
7 changes: 3 additions & 4 deletions tensorboardX/torchvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from __future__ import unicode_literals

import gc
import six
import time

from functools import wraps
Expand Down Expand Up @@ -43,15 +42,15 @@ def unregister(self, *args):
gc.collect()

def __getattr__(self, attr):
for _, subscriber in six.iteritems(self.subscribers):
for _, subscriber in self.subscribers.items():
def wrapper(*args, **kwargs):
for _, subscriber in six.iteritems(self.subscribers):
for _, subscriber in self.subscribers.items():
if hasattr(subscriber, attr):
getattr(subscriber, attr)(*args, **kwargs)
return wrapper
raise AttributeError

# Handle writer management (open/close) for the user
def __del__(self):
for _, subscriber in six.iteritems(self.subscribers):
for _, subscriber in self.subscribers.items():
subscriber.close()
5 changes: 2 additions & 3 deletions tensorboardX/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import json
import os
import numpy
import six
import time
import logging
import atexit
Expand Down Expand Up @@ -337,7 +336,7 @@ def _check_caffe2_blob(self, item):
workspace.FetchBlob(blob_name)
workspace.FetchBlobs([blob_name1, blob_name2, ...])
"""
return isinstance(item, six.string_types)
return isinstance(item, str)

def _get_file_writer(self):
"""Returns the default FileWriter instance. Recreates it if closed."""
Expand Down Expand Up @@ -558,7 +557,7 @@ def add_histogram(
"""
if self._check_caffe2_blob(values):
values = workspace.FetchBlob(values)
if isinstance(bins, six.string_types) and bins == 'tensorflow':
if isinstance(bins, str) and bins == 'tensorflow':
bins = self.default_bins
self._get_file_writer().add_summary(
histogram(tag, values, bins, max_bins=max_bins), global_step, walltime)
Expand Down
3 changes: 1 addition & 2 deletions tensorboardX/x2num.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import logging
import numpy as np
import six
logger = logging.getLogger(__name__)


Expand All @@ -21,7 +20,7 @@ def make_np(x):
return check_nan(np.array(x))
if isinstance(x, np.ndarray):
return check_nan(x)
if isinstance(x, six.string_types): # Caffe2 will pass name of blob(s) to fetch
if isinstance(x, str): # Caffe2 will pass name of blob(s) to fetch
return check_nan(prepare_caffe2(x))
if np.isscalar(x):
return check_nan(np.array([x]))
Expand Down
6 changes: 2 additions & 4 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
flake8
pytest
torch
six
protobuf==3.15
torchvision
protobuf==3.20.1
numpy==1.21.0
pillow
tensorboard
boto3
future
matplotlib
moto
soundfile
Expand Down
1 change: 0 additions & 1 deletion tests/record_writer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from __future__ import division
from __future__ import print_function

import six
import os
from tensorboardX.record_writer import RecordWriter
from tensorboard.compat.tensorflow_stub.pywrap_tensorflow import PyRecordReader_New
Expand Down