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

Add mypy + pytest global config + small fixes. #259

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 16 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
1 change: 1 addition & 0 deletions argoverse/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VERSION = "1.1.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in setup.cfg.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the version required to be placed here? This probably wouldnt be a place I would look for the version number, so do we need to write it in 2 places now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the first method listed here: https://packaging.python.org/guides/single-sourcing-package-version/#single-sourcing-the-package-version. Although, they use __version__ instead of VERSION.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to use __version__.

4 changes: 2 additions & 2 deletions demo_usage/cuboids_to_bboxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def main(args: Any):
logger.info(args)

if args.log_ids is None:
logger.error(f"Please provide a comma seperated list of log ids")
raise ValueError(f"Please provide a comma seperated list of log ids")
logger.error("Please provide a comma seperated list of log ids")
raise ValueError("Please provide a comma seperated list of log ids")
benjaminrwilson marked this conversation as resolved.
Show resolved Hide resolved

main(args)
6 changes: 3 additions & 3 deletions demo_usage/visualize_30hz_benchmark_data_on_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def render_bev_labels_mpl(
city_to_egovehicle_se3: Transformation from egovehicle frame to city frame
avm: ArgoverseMap instance
"""
if axis is not "city_axis":
if axis != "city_axis":
benjaminrwilson marked this conversation as resolved.
Show resolved Hide resolved
# rendering instead in the egovehicle reference frame
for da_idx, local_da in enumerate(local_das):
local_da = city_to_egovehicle_se3.inverse_transform_point_cloud(local_da)
Expand All @@ -262,7 +262,7 @@ def render_bev_labels_mpl(
draw_lane_polygons(ax, local_lane_polygons)
draw_lane_polygons(ax, local_das, color="tab:pink")

if axis is not "city_axis":
if axis != "city_axis":
benjaminrwilson marked this conversation as resolved.
Show resolved Hide resolved
lidar_pts = rotate_polygon_about_pt(lidar_pts, city_to_egovehicle_se3.rotation, np.zeros((3,)))
draw_point_cloud_bev(ax, lidar_pts)

Expand All @@ -283,7 +283,7 @@ def render_bev_labels_mpl(
bbox_ego_frame = rotate_polygon_about_pt(
bbox_ego_frame, city_to_egovehicle_se3.rotation, np.zeros((3,))
)
if axis is "city_axis":
if axis == "city_axis":
benjaminrwilson marked this conversation as resolved.
Show resolved Hide resolved
plot_bbox_2D(ax, bbox_city_fr, color)
if self.plot_lane_tangent_arrows:
bbox_center = np.mean(bbox_city_fr, axis=0)
Expand Down
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[tool.black]
line-length = 120

Comment on lines +1 to +3
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted alphabetically.

[tool.isort]
known_first_party = "argoverse"
known_third_party = "mayavi,pytest,colour,descartes,imageio,matplotlib,motmetrics,numpy,cv2,pandas,pillow,imageio,pyntcloud,scipy,shapely,sklearn"
Expand All @@ -6,5 +9,9 @@ line_length = 120
multi_line_output = 3
profile = "black"

[tool.black]
line-length = 120
[tool.mypy]
ignore_missing_imports = true
strict = true
Comment on lines +12 to +14
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mypy settings are supported in pyproject.toml now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a specific version of mypy that we need to enforce, to be able to use this functionality?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


[tool.pytest.ini_options]
addopts = "--cov argoverse --cov-append --cov-branch --cov-report=term-missing"
Comment on lines +16 to +17
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add pytest settings into pyproject.toml.

57 changes: 57 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,59 @@
[metadata]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static declaration of metadata previously listed in setup.py.

author = Argo AI
author_email = [email protected]
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: POSIX
Operating System :: MacOS
Programming Language :: Python :: 3
Topic :: Scientific/Engineering :: Artificial Intelligence
description_file = README.md
keywords =
self-driving-car
dataset-tools
license = MIT
name = argoverse
url = https://www.argoverse.org
version = attr: argoverse.VERSION

[options]
zip_safe = False
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we want zip_safe = False?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just a default option listed here: https://setuptools.readthedocs.io/en/latest/userguide/declarative_config.html?highlight=zip_safe. I don't have a strong opinion on it. setuptools will automatically try to determine the setting if we remove it, which might be useful.

include_package_data = True
packages = find:
install_requires =
colour
descartes
imageio
h5py
hydra-core ==1.1.0
lap
matplotlib
motmetrics ==1.1.3
numpy ==1.19
omegaconf ==2.1.0
opencv-python >=4.1.0.25
pandas >=0.23.1
pillow
imageio
pyntcloud >=0.1.0
scipy >=1.4.0
shapely
sklearn
tqdm
typing_extensions

[options.package_data]
argoverse = argoverse/visualization/data/**/*

[options.packages.find]
exclude =
integration_tests
map_files
tests

[flake8]
enable_extensions = G
ignore = E203,E704,E711,E722,E741,W291,W293,W391,W503,F821,F401,F811,F841,P101,G004,G002,I201,I100,I101
max_line_length = 120
59 changes: 2 additions & 57 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,12 @@
"""

import platform
import sys
from codecs import open # To use a consistent encoding
from os import path

# Always prefer setuptools over distutils
from setuptools import find_packages, setup

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, "README.md"), encoding="utf-8") as f:
long_description = f.read()


if platform.system() == "Windows":
print("Argoverse currently does not support Windows, please use Linux/Mac OS")
sys.exit(1)
exit(1)

setup(
name="argoverse",
version="1.0.1",
description="",
long_description=long_description,
url="https://www.argoverse.org",
author="Argo AI",
author_email="[email protected]",
license="MIT",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: POSIX",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
],
keywords="self-driving-car dataset-tools",
packages=find_packages(exclude=["tests", "integration_tests", "map_files"]),
package_data={"argoverse": ["argoverse/visualization/data/**/*"]},
include_package_data=True,
python_requires=">= 3.7",
install_requires=[
"colour",
"descartes",
"imageio",
"h5py",
"hydra-core==1.1.0",
"lap",
"matplotlib",
"motmetrics==1.1.3",
"numpy==1.19",
"omegaconf==2.1.0",
"opencv-python>=4.1.0.25",
"pandas>=0.23.1",
"pillow",
"imageio",
"pyntcloud>=0.1.0",
"scipy>=1.4.0",
"shapely",
"sklearn",
"tqdm",
"typing_extensions",
],
)
setup()
7 changes: 4 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ deps =

commands =
python3 -m pip install numba
pytest tests --cov argoverse --cov-append --cov-branch --cov-report=term-missing
flake8 --max-line-length 120 --ignore E203,E704,E711,E722,E741,W291,W293,W391,W503,F821,F401,F811,F841,P101,G004,G002,I201,I100,I101 --enable-extensions G argoverse
mypy --ignore-missing --strict argoverse
pytest tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have we verified that these options get picked up from the pyproject.toml file in practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of these can be verified by looking at the tox run in our Github workflow. I'll verify once again after we've settled on the other changes.

flake8 argoverse
mypy argoverse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These flags reside in either setup.cfg or pyproject.toml now.


depends =
py3{7,8}: clean
Expand Down