Skip to content

Commit

Permalink
Merge pull request #460 from Parsely/feature/remove_python2
Browse files Browse the repository at this point in the history
Remove Python 2 compatibility code
  • Loading branch information
dan-blanchard committed Apr 9, 2019
2 parents 280535a + b7de5ba commit 8aa1e6f
Show file tree
Hide file tree
Showing 46 changed files with 59 additions and 218 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ cache:
directories:
- $HOME/.cache/pip
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.7-dev"
- "pypy2.7-6.0"
- "pypy3.5-6.0"
- "3.8-dev"
- "pypy3.5"

matrix:
fast_finish: true
allow_failures:
- python: '3.7-dev'
- python: '3.8-dev'

dist:
- xenial
Expand Down
49 changes: 0 additions & 49 deletions conda.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions doc/source/topologies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ One limitation of the Thrift interface we use to send the topology to Storm is
that the constructors for Java components can only be passed basic Python data
types: `bool`, `bytes`, `float`, `int`, and `str`.

.. note::
If you are passing strings as constructor arguments to Java components via
the ``args_list`` parameter, you must use `unicode` literals to do so in
Python 2. Otherwise, Storm will raise an exception.

Components in Other Languages
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ requests
ruamel.yaml
setuptools
simplejson
six>=1.5
texttable
thriftpy>=0.3.2
contextlib2; python_version < '3'
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[bdist_wheel]
universal=1

[nosetests]
logging-clear-handlers = 1
verbosity = 2
Expand Down
38 changes: 16 additions & 22 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
Copyright 2014-2017 Parsely, Inc.
Copyright 2014-2019 Parsely, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -15,7 +15,6 @@
limitations under the License.
"""
import re
import sys

from setuptools import setup, find_packages

Expand All @@ -34,27 +33,12 @@ def readme():


install_requires = [
"cython",
"jinja2",
"requests",
"texttable",
"six>=1.5",
"simplejson",
"pystorm>=3.1.1",
"thriftpy>=0.3.2",
"ruamel.yaml",
"fabric3",
l.split("#")[0].strip()
for l in open("requirements.txt").readlines()
if not l.startswith(("#", "-"))
]

if sys.version_info.major < 3:
install_requires.append("contextlib2")

lint_requires = ["pep8", "pyflakes"]

if sys.version_info.major < 3:
tests_require = ["graphviz", "mock", "pytest", "unittest2"]
else:
tests_require = ["graphviz", "pytest"]
tests_require = ["graphviz", "pytest"]

setup(
name="streamparse",
Expand Down Expand Up @@ -82,8 +66,18 @@ def readme():
"test": tests_require,
"all": install_requires + tests_require,
"docs": ["sphinx"] + tests_require,
"lint": lint_requires,
},
zip_safe=False,
include_package_data=True,
classifiers=[
"License :: OSI Approved :: Apache Software License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
],
)
4 changes: 1 addition & 3 deletions streamparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
:organization: Parsely
"""

from __future__ import absolute_import, print_function, unicode_literals

import logging

from . import bolt, cli, component, dsl, spout, storm
Expand Down Expand Up @@ -53,7 +51,7 @@
]

__license__ = """
Copyright 2014-2017 Parsely, Inc.
Copyright 2014-2019 Parsely, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 0 additions & 2 deletions streamparse/bootstrap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Utilities for bootstrapping streamparse projects.
"""
from __future__ import absolute_import, print_function, unicode_literals

from contextlib import contextmanager
import os
import sys
Expand Down
9 changes: 4 additions & 5 deletions streamparse/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import warnings

from ruamel import yaml
from six import integer_types, string_types

from streamparse.util import get_storm_workers

Expand Down Expand Up @@ -305,11 +304,11 @@ def resolve_options(
storm_options["pystorm.log.path"] = log_path
if log_file:
storm_options["pystorm.log.file"] = log_file
if isinstance(log_config.get("max_bytes"), integer_types):
if isinstance(log_config.get("max_bytes"), int):
storm_options["pystorm.log.max_bytes"] = log_config["max_bytes"]
if isinstance(log_config.get("backup_count"), integer_types):
if isinstance(log_config.get("backup_count"), int):
storm_options["pystorm.log.backup_count"] = log_config["backup_count"]
if isinstance(log_config.get("level"), string_types):
if isinstance(log_config.get("level"), str):
storm_options["pystorm.log.level"] = log_config["level"].lower()

# Make sure virtualenv options are present here
Expand All @@ -334,7 +333,7 @@ def resolve_options(
if not local_only:
if not storm_options.get("storm.workers.list"):
storm_options["storm.workers.list"] = get_storm_workers(env_config)
elif isinstance(storm_options["storm.workers.list"], string_types):
elif isinstance(storm_options["storm.workers.list"], str):
storm_options["storm.workers.list"] = storm_options[
"storm.workers.list"
].split(",")
Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/jar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Create a JAR that can be used to deploy a topology to Storm.
"""

from __future__ import absolute_import, print_function, unicode_literals

import os
import shutil
import sys
Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/kill.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Kill the specified Storm topology.
"""

from __future__ import absolute_import

from ..thrift import KillOptions
from ..util import (
get_topology_definition,
Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
List the currently running Storm topologies.
"""

from __future__ import absolute_import

from ..util import get_env_config, get_nimbus_client, print_stats_table, ssh_tunnel
from ..thrift import TopologySummary
from .common import add_config, add_environment, add_timeout
Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Create new streamparse project template.
"""

from __future__ import absolute_import

from streamparse.bootstrap import quickstart


Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/remove_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Remove all logs from Storm workers for the specified Storm topology.
"""

from __future__ import absolute_import, print_function

from fabric.api import env, execute, parallel

from .common import (
Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
also need to add [org.apache.storm/flux-core "1.0.1"] to dependencies.
"""

from __future__ import absolute_import, print_function

from argparse import RawDescriptionHelpFormatter
from tempfile import NamedTemporaryFile

Expand Down
9 changes: 3 additions & 6 deletions streamparse/cli/slot_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
Display slots used by every topology on the cluster
"""

from __future__ import absolute_import, print_function

from collections import Counter, defaultdict

from pkg_resources import parse_version
from six import iteritems

from .common import add_config, add_environment
from ..util import get_ui_json, get_ui_jsons, print_stats_table, storm_lib_version
Expand Down Expand Up @@ -57,13 +54,13 @@ def display_slot_usage(env_name, config_file=None):
env_name,
(
component_path.format(topology=topology, component=comp)
for topology, comp_list in iteritems(topology_components)
for topology, comp_list in topology_components.items()
for comp in comp_list
),
config_file=config_file,
)

for request_url, comp_detail in iteritems(comp_details):
for request_url, comp_detail in comp_details.items():
topology = request_url.split("/")[4]
topology_detail_json = topology_detail_jsons[
topology_detail_path.format(topology=topology)
Expand All @@ -88,7 +85,7 @@ def display_slot_usage(env_name, config_file=None):
for topology in topology_names
]
)
for host, host_dict in sorted(iteritems(topology_worker_ports))
for host, host_dict in sorted(topology_worker_ports.items())
]
print_stats_table("Slot (and Executor) Counts by Topology", rows, columns)

Expand Down
2 changes: 0 additions & 2 deletions streamparse/cli/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
subparser as needed.
"""

from __future__ import absolute_import

import argparse
import importlib
import os
Expand Down
6 changes: 1 addition & 5 deletions streamparse/cli/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
Display stats about running Storm topologies.
"""

from __future__ import absolute_import, print_function

import sys
from itertools import chain

from pkg_resources import parse_version
from six import string_types
from six.moves import map, zip

from ..util import (
get_env_config,
Expand Down Expand Up @@ -159,7 +155,7 @@ def _print_topology_status(env_name, topology_name, config_file=None):
def _get_component_ui_detail(
env_name, topology_name, component_names, config_file=None
):
if isinstance(component_names, string_types):
if isinstance(component_names, str):
component_names = [component_names]
env_name = get_env_config(env_name, config_file=config_file)[0]
topology_id = _get_topology_id(env_name, topology_name, config_file=config_file)
Expand Down
10 changes: 3 additions & 7 deletions streamparse/cli/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Submit a Storm topology to Nimbus.
"""

from __future__ import absolute_import, print_function, unicode_literals

import importlib
import os
import sys
Expand All @@ -13,7 +11,6 @@
import simplejson as json
from fabric.api import env
from pkg_resources import parse_version
from six import itervalues

from ..dsl.component import JavaComponentSpec
from ..thrift import ShellComponent, SubmitOptions, TopologyInitialStatus
Expand Down Expand Up @@ -243,13 +240,13 @@ def submit_topology(
[env.virtualenv_root, virtualenv_name, "bin", "streamparse_run"]
)
# Update python paths in bolts
for thrift_bolt in itervalues(topology_class.thrift_bolts):
for thrift_bolt in topology_class.thrift_bolts.values():
inner_shell = thrift_bolt.bolt_object.shell
if isinstance(inner_shell, ShellComponent):
if "streamparse_run" in inner_shell.execution_command:
inner_shell.execution_command = streamparse_run_path
# Update python paths in spouts
for thrift_spout in itervalues(topology_class.thrift_spouts):
for thrift_spout in topology_class.thrift_spouts.values():
inner_shell = thrift_spout.spout_object.shell
if isinstance(inner_shell, ShellComponent):
if "streamparse_run" in inner_shell.execution_command:
Expand All @@ -260,8 +257,7 @@ def submit_topology(

# Set parallelism based on env_name if necessary
for thrift_component in chain(
itervalues(topology_class.thrift_bolts),
itervalues(topology_class.thrift_spouts),
topology_class.thrift_bolts.values(), topology_class.thrift_spouts.values()
):
par_hint = thrift_component.common.parallelism_hint
if isinstance(par_hint, dict):
Expand Down

0 comments on commit 8aa1e6f

Please sign in to comment.