Skip to content

Commit

Permalink
Changed requirements so that main.txt only includes essential depende…
Browse files Browse the repository at this point in the history
…ncies (#294)

* Changed requirements so that main.txt only includes essential dependencies.

* Reverted black, mypi, flake and isort versions in requirements file.

* Fixed some mypy issues. Added drm to dev requirements so unit tests pass.
  • Loading branch information
luisenp authored Sep 9, 2022
1 parent 6822471 commit dfcbcc4
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ pip install -e ".[dev]"
```
and follow the more detailed instructions in [CONTRIBUTING](https://github.com/facebookresearch/theseus/blob/main/CONTRIBUTING.md).

### Running unit tests
### Running unit tests (requires `dev` installation)
```bash
pytest theseus
python -m pytest theseus
```
By default, unit tests include tests for our CUDA extensions. You can add the option `-m "not cudaext"` to skip them when installing without CUDA support.

Expand Down
8 changes: 8 additions & 0 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ If you are interested in contributing to ``theseus``, instead install using
and follow the more detailed instructions in `CONTRIBUTING <https://github.com/facebookresearch/theseus/blob/main/CONTRIBUTING.md>`_.

Unit tests
""""""""""
With ``dev`` installation, you can run unit tests via

.. code-block:: bash
python -m pytest theseus
By default, unit tests include tests for our CUDA extensions. You can add the option ``-m "not cudaext"`` to
skip them when installing without CUDA support.

Expand Down
5 changes: 5 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ The motion planning and tactile estimation examples require `hydra` installation
```bash
pip install hydra-core
```
The backward modes example requires `numdifftools`, which you can install with

```bash
pip install numdifftools
```

The homography example requires `kornia` and `OpenCV`, which you can install with

Expand Down
10 changes: 5 additions & 5 deletions examples/homography_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from torch.utils.data import DataLoader, Dataset

import theseus as th
from theseus.third_party.easyaug import RandomGeoAug, GeoAugParam, RandomPhotoAug
from theseus.third_party.easyaug import GeoAugParam, RandomGeoAug, RandomPhotoAug
from theseus.third_party.utils import grid_sample

FONT = cv2.FONT_HERSHEY_DUPLEX
Expand All @@ -36,10 +36,10 @@ def prepare_data():
dataset_root = os.path.join(os.getcwd(), "data")
chunks = [
"revisitop1m.1",
#"revisitop1m.2", # Uncomment for more data.
#"revisitop1m.3",
#"revisitop1m.4",
#"revisitop1m.5",
# "revisitop1m.2", # Uncomment for more data.
# "revisitop1m.3",
# "revisitop1m.4",
# "revisitop1m.5",
]
dataset_paths = []
for chunk in chunks:
Expand Down
3 changes: 3 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ mypy>=0.910
nox==2020.8.22
pre-commit>=2.9.2
isort>=5.6.4
differentiable-robot-model>=0.2.3
types-PyYAML==5.4.3
numdifftools>=0.9.40
mock>=4.0.3
types-mock>=4.0.8
Sphinx==5.0.2
sphinx-rtd-theme==1.0.0
3 changes: 0 additions & 3 deletions requirements/main.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
differentiable-robot-model>=0.2.3
numpy>=1.19.2
scipy>=1.5.3
scikit-sparse>=0.4.5
# torch>=1.7.1 will do separate install instructions for now (CUDA dependent)
pytest>=6.2.1
numdifftools>=0.9.40
pybind11>=2.7.1
mock>=4.0.3
functorch>=0.2.1
10 changes: 9 additions & 1 deletion theseus/embodied/kinematics/kinematics_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import abc
from typing import Dict, Optional, Union

import differentiable_robot_model as drm
import torch

from theseus.geometry import SE3, LieGroup, Point2, Vector
Expand Down Expand Up @@ -38,6 +37,15 @@ def forward_kinematics(self, robot_pose: RobotModelInput) -> Dict[str, LieGroup]

class UrdfRobotModel(KinematicsModel):
def __init__(self, urdf_path: str):
try:
import differentiable_robot_model as drm
except ModuleNotFoundError as e:
print(
"UrdfRobotModel requires installing differentiable-robot-model. "
"Please run `pip install differentiable-robot-model`."
)
raise e

self.drm_model = drm.DifferentiableRobotModel(urdf_path)

def _postprocess_quaternion(self, quat):
Expand Down
2 changes: 1 addition & 1 deletion theseus/optimizer/linear_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
row_ptr: np.ndarray,
num_rows: int,
num_cols: int,
dtype: np.dtype = np.float_,
dtype: np.dtype = np.float_, # type: ignore
):
self.col_ind = col_ind
self.row_ptr = row_ptr
Expand Down
2 changes: 1 addition & 1 deletion theseus/theseus_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def jacobians(self) -> Tuple[List[torch.Tensor], torch.Tensor]:
return [self.var.project(euclidean_grad, is_sparse=True)], self.error()

def dim(self) -> int:
return np.prod(self.var.tensor.shape[1:])
return int(np.prod(self.var.tensor.shape[1:]))

def _copy_impl(self, new_name: Optional[str] = None) -> "CostFunction":
return _DLMPerturbation(
Expand Down
10 changes: 5 additions & 5 deletions theseus/utils/examples/tactile_pose_estimation/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ def __init__(
stop = max(int(np.ceil(num_episodes * val_ratio)), 2)
idx = order[:stop] if data_mode == "val" else order[stop:]

self.img_feats = data["img_feats"][idx]
self.eff_poses = data["eff_poses"][idx]
self.obj_poses = data["obj_poses"][idx]
self.contact_episode = data["contact_episode"][idx]
self.contact_flag = data["contact_flag"][idx]
self.img_feats = data["img_feats"][idx] # type: ignore
self.eff_poses = data["eff_poses"][idx] # type: ignore
self.obj_poses = data["obj_poses"][idx] # type: ignore
self.contact_episode = data["contact_episode"][idx] # type: ignore
self.contact_flag = data["contact_flag"][idx] # type: ignore
# Check sizes of the attributes assigned above
self.dataset_size: int = -1
for key in data:
Expand Down

0 comments on commit dfcbcc4

Please sign in to comment.