Skip to content

Commit

Permalink
Remove torch/motmetrics/pandas requirements and skip related tests (n…
Browse files Browse the repository at this point in the history
…utonomy#510)

* Skip tests with non-standard requirements

* Silence test tqdm

Co-authored-by: Holger Caesar <holger.caesar@motional.com>
  • Loading branch information
holger-motional and Holger Caesar authored Dec 7, 2020
1 parent 25096fd commit 5f337c5
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 13 deletions.
10 changes: 9 additions & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Download the devkit to your home directory using:
```
cd && git clone https://github.com/nutonomy/nuscenes-devkit.git
```
*Note:* The pip package does not support the prediction or tracking code.
For these, you will need to download the source code and [manually install the requirements](#install-required-packages).

## Install Python

The devkit is tested for Python 3.6 onwards, but we recommend to use Python 3.7.
Expand Down Expand Up @@ -104,7 +107,12 @@ To install the required packages, run the following command in your favourite vi
```
pip install -r setup/requirements.txt
```
**Note:** The requirements file is internally divided into base requirements (`base`) and requirements specific to certain products or challenges (`nuimages`, `prediction` and `tracking`). If you only plan to use a subset of the codebase, feel free to comment out the lines that you do not need.
**Note:** The requirements file is internally divided into base requirements (`base`) and requirements specific to certain products or challenges (`nuimages`, `prediction` and `tracking`).
From December 2020 onwards we are excluding the `prediction` and `tracking` requirements by default to decrease the number of packages that are installed and avoid incompatibility with other pip packages.
If you want to install these requirements nevertheless, please run the following for `prediction` (and analog for `tracking`):
```
pip install -r setup/requirements/requirements_prediction.txt
```

## Setup environment variable
Finally, if you want to run the unit tests you need to point the devkit to the `nuscenes` folder on your disk.
Expand Down
7 changes: 6 additions & 1 deletion python-sdk/nuscenes/eval/tracking/algo.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
"""
import os
from typing import List, Dict, Callable, Tuple
import unittest

import numpy as np
import pandas
import sklearn
import tqdm

try:
import pandas
except ModuleNotFoundError:
raise unittest.SkipTest('Skipping test as pandas was not found!')

from nuscenes.eval.tracking.constants import MOT_METRIC_MAP, TRACKING_METRICS
from nuscenes.eval.tracking.data_classes import TrackingBox, TrackingMetricData
from nuscenes.eval.tracking.mot import MOTAccumulatorCustom
Expand Down
9 changes: 7 additions & 2 deletions python-sdk/nuscenes/eval/tracking/utils.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
# nuScenes dev-kit.
# Code written by Holger Caesar, 2019.

import unittest
import warnings
from typing import Optional, Dict

import motmetrics
import numpy as np
from motmetrics.metrics import MetricsHost

try:
import motmetrics
from motmetrics.metrics import MetricsHost
except ModuleNotFoundError:
raise unittest.SkipTest('Skipping test as motmetrics was not found!')

from nuscenes.eval.tracking.data_classes import TrackingMetrics
from nuscenes.eval.tracking.metrics import motar, mota_custom, motp_custom, faf, track_initialization_duration, \
Expand Down
2 changes: 1 addition & 1 deletion python-sdk/nuscenes/map_expansion/tests/test_all_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_egoposes_on_map(self):
whitelist = ['scene-0499', 'scene-0501', 'scene-0502', 'scene-0515', 'scene-0517']

invalid_scenes = []
for scene in tqdm.tqdm(nusc.scene):
for scene in tqdm.tqdm(nusc.scene, leave=False):
if scene['name'] in whitelist:
continue

Expand Down
7 changes: 5 additions & 2 deletions python-sdk/nuscenes/prediction/tests/test_backbone.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import unittest

import torch
from torchvision.models.resnet import BasicBlock, Bottleneck
try:
import torch
from torchvision.models.resnet import BasicBlock, Bottleneck
except ModuleNotFoundError:
raise unittest.SkipTest('Skipping test as torch was not found!')

from nuscenes.prediction.models.backbone import ResNetBackbone, MobileNetBackbone

Expand Down
7 changes: 5 additions & 2 deletions python-sdk/nuscenes/prediction/tests/test_covernet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
import math
import unittest

import torch
from torch.nn.functional import cross_entropy
try:
import torch
from torch.nn.functional import cross_entropy
except ModuleNotFoundError:
raise unittest.SkipTest('Skipping test as torch was not found!')

from nuscenes.prediction.models.backbone import ResNetBackbone
from nuscenes.prediction.models.covernet import mean_pointwise_l2_distance, ConstantLatticeLoss, CoverNet
Expand Down
5 changes: 4 additions & 1 deletion python-sdk/nuscenes/prediction/tests/test_mtp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import unittest

import torch
try:
import torch
except ModuleNotFoundError:
raise unittest.SkipTest('Skipping test as torch was not found!')

from nuscenes.prediction.models import backbone
from nuscenes.prediction.models import mtp
Expand Down
5 changes: 4 additions & 1 deletion python-sdk/nuscenes/prediction/tests/test_mtp_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import math
import unittest

import torch
try:
import torch
except ModuleNotFoundError:
raise unittest.SkipTest('Skipping test as torch was not found!')

from nuscenes.prediction.models import mtp

Expand Down
4 changes: 2 additions & 2 deletions setup/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r requirements/requirements_base.txt
-r requirements/requirements_prediction.txt
-r requirements/requirements_tracking.txt
-r requirements/requirements_nuimages.txt
# -r requirements/requirements_prediction.txt # Uncomment this for the prediction code
# -r requirements/requirements_tracking.txt # Uncomment this for the tracking code

0 comments on commit 5f337c5

Please sign in to comment.