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

[Feature] Add more comprehensive error handling #5

Merged
merged 13 commits into from
Sep 18, 2023
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
13 changes: 7 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ We use the following tools for linting and formatting:
Style configurations of black and isort can be found in [pyproject.toml](../pyproject.toml).

We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `black`, `isort`, `trailing whitespaces`,
fixes `end-of-files`, sorts `requirments.txt` automatically on every commit.
fixes `end-of-files` automatically on every commit.
The config for a pre-commit hook is stored in [.pre-commit-config](../.pre-commit-config.yaml).

After you clone the repository, you will need to install initialize pre-commit hook.
Expand All @@ -47,21 +47,22 @@ pre-commit install
```

If you are facing an issue when installing markdown lint, you may install ruby for markdown lint by
referring to [this repo](https://github.com/innerlee/setup) by following the usage and taking [`zzruby.sh`](https://github.com/innerlee/setup/blob/master/zzruby.sh)
referring to [this repo](https://github.com/innerlee/setup)
by following the usage and taking [`zzruby.sh`](https://github.com/innerlee/setup/blob/master/zzruby.sh)

or by the following steps
or by the following steps

```shell
```shell
# install rvm
curl -L https://get.rvm.io | bash -s -- --autolibs=read-fail
rvm autolibs disable
# install ruby
# install ruby
rvm install 2.7.1
```

After this on every commit check code linters and formatter will be enforced.

> Before you create a PR, make sure that your code lints and is formatted by yapf.
> Before you create a PR, make sure that your code lints and is formatted by black.

### C++ and CUDA

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

<br/>

<div align="center">

[![Documentation](https://readthedocs.org/projects/xrfeitoria/badge/?version=latest)](https://xrfeitoria.readthedocs.io/en/latest/?badge=latest)
[![actions](https://github.com/openxrlab/xrfeitoria/workflows/lint/badge.svg)](https://github.com/openxrlab/xrfeitoria/actions)
[![PyPI](https://img.shields.io/pypi/v/xrfeitoria)](https://pypi.org/project/xrfeitoria/)
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)

</div>

## Introduction

XRFeitoria is a rendering toolbox for generating synthetic data photorealistic with ground-truth annotations.
Expand Down Expand Up @@ -61,10 +65,14 @@ wget https://graphics.stanford.edu/~mdfisher/Data/Meshes/bunny.obj
xf-render bunny.obj
```

### Documentation

The reference documentation is available on [readthedocs](https://xrfeitoria.readthedocs.io/en/latest/).

### Tutorials

There are several [tutorials](/tutorials/).
You can read them [here](https://openxrlab-share.oss-cn-hongkong.aliyuncs.com/xrfeitoria/docs/en/_build/html/src/Tutorials.html).
You can read them [here](https://xrfeitoria.readthedocs.io/en/latest/src/Tutorials.html).


### Sample codes
Expand Down
8 changes: 4 additions & 4 deletions docs/en/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
### Setup Python Environment

```bash
pip install -r requirements/docs.txt
pip install xrfeitoria[doc]
```

### Install Graphviz

- Windows: Download and install from [link](https://graphviz.org/download/#windows),
and add the `bin` folder to `PATH` environment variable.
- Windows: [Download](https://graphviz.org/download/#windows) and install,
and add the `bin` folder to `PATH` environment variable

- Linux: Install with `sudo apt install graphviz`,
- Linux: `sudo apt install graphviz`

### Install pandoc

Expand Down
2 changes: 1 addition & 1 deletion docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Requirements

src/cli.md
src/Tutorials.rst
src/Samples.rst
Samples <https://github.com/openxrlab/xrfeitoria/tree/main/samples>

--------

Expand Down
4 changes: 3 additions & 1 deletion docs/en/src/Tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ The following tutorials cover the basic operations needed to render with ``XRFei
Extra Samples
--------------

For more advanced examples, see the :ref:`samples` section.
.. _samples: https://github.com/openxrlab/xrfeitoria/tree/main/samples/

For more advanced examples, see the `samples`_ section.
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ requires-python = ">=3.8, <3.11"
license = { text = 'Apache License 2.0' }
classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand All @@ -32,6 +34,7 @@ dependencies = [
"fake-bpy-module-latest",
"numpy>=1,<2",
"loguru<1",
"packaging>=23,<24",
"pydantic>=2,<3",
"psutil>=5,<6",
"rich>=13,<14",
Expand All @@ -56,15 +59,12 @@ doc = [
"sphinx-rtd-theme==1.3.0",
"sphinx-tabs==3.4.1",
"enum-tools[sphinx]",

# https://graphviz.org/download/#windows
# sudo apt install pandoc
# sudo apt install graphviz
]

[project.urls]
"Homepage" = "https://github.com/openxrlab/xrfeitoria"
"Bug Tracker" = "https://github.com/openxrlab/xrfeitoria/issues"
"Documentation" = "https://xrfeitoria.readthedocs.io/en/latest/"

[project.scripts]
xf-render = "xrfeitoria.cmd.render:app"
Expand Down
12 changes: 10 additions & 2 deletions samples/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
# Samples

## Configure
First, configure the **executable path** of blender or unreal by execute:
## Clone

```bash
git clone https://github.com/openxrlab/xrfeitoria.git
cd xrfeitoria
```

## Setup the environment

After [installation](../README.md#Installation), configure the **executable path** of blender or unreal by executing:

```bash
python -m samples.setup
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/XRFeitoriaBpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
bl_info = {
'name': 'XRFeitoriaBpy',
'author': 'OpenXRLab',
'version': (0, 1, 0),
'version': (0, 5, 0),
'blender': (3, 3, 0),
'category': 'Tools',
}
Expand Down
10 changes: 5 additions & 5 deletions src/XRFeitoriaUnreal/XRFeitoriaUnreal.uplugin
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "1.0",
"VersionName": "0.5.0",
"FriendlyName": "XRFeitoriaUnreal",
"Description": "",
"Category": "Other",
"CreatedBy": "",
"Description": "OpenXRLab Synthetic Data Rendering Toolbox",
"Category": "Scripting",
"CreatedBy": "OpenXRLab",
"CreatedByURL": "",
"DocsURL": "",
"DocsURL": "https://xrfeitoria.readthedocs.io/en/latest/",
"MarketplaceURL": "",
"SupportURL": "",
"CanContainContent": true,
Expand Down
9 changes: 1 addition & 8 deletions tutorials/01_get_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@
"source": [
"## Import XRFeitoria\n",
"\n",
"After [Installing][1], import ``XRfeitoria`` by\n",
"\n",
"[1]: http://xrfeitoria.readthedocs.io/en/latest/installation.html"
"After [Installing](../../index.rst#installation), import ``XRfeitoria`` by"
]
},
{
Expand Down Expand Up @@ -152,11 +150,6 @@
"source": [
"Ref to [api docs](../../apis/xrfeitoria.rst), you can always use ``with`` statement to ensure the engine is closed when the codes are finished."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand Down
19 changes: 10 additions & 9 deletions xrfeitoria/data_structure/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,28 @@
PathLike = Union[str, Path]
actor_info_type = TypedDict('actor_info', {'actor_name': str, 'mask_color': Tuple[int, int, int]})

##### Package Constants #####

package_name = 'XRFeitoria'
plugin_name_blender = 'XRFeitoriaBpy'
plugin_name_unreal = 'XRFeitoriaUnreal'
xf_obj_name = '[XF]{obj_type}-{obj_idx:03d}'

##### Path Constants #####

tmp_dir = Path.home() / '.tmp' / 'XRFeitoria'
tmp_dir = Path.home() / '.tmp' / package_name
tmp_dir.mkdir(parents=True, exist_ok=True)
actor_infos = 'actor_infos'
cam_param_dir = 'camera_params'

config_dir = Path.home() / '.config' / 'XRFeitoria'
config_dir = Path.home() / '.config' / package_name
config_dir.mkdir(parents=True, exist_ok=True)
config_path = config_dir / 'config.ini'
ConfigDict = TypedDict('ConfigDict', {'blender_exec': Optional[Path], 'unreal_exec': Optional[Path]})

##### Package Constants #####

plugin_name_blender = 'XRFeitoriaBpy'
plugin_name_unreal = 'XRFeitoriaUnreal'
xf_obj_name = '[XF]{obj_type}-{obj_idx:03d}'

##### Blender Constants #####

default_level_blender = 'XRFeitoria'
default_level_blender = package_name

##### Unreal Constants #####

Expand Down
18 changes: 7 additions & 11 deletions xrfeitoria/utils/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def download(url: str, dst_dir: Path, verbose: bool = True) -> Path:
Returns:
Path: The path to the downloaded file.
"""
dst_dir = Path(dst_dir).resolve()
dst_dir.mkdir(parents=True, exist_ok=True)
filename = url.split('/')[-1]
dst_path = Path(dst_dir).resolve() / filename
Expand All @@ -46,32 +47,27 @@ def download(url: str, dst_dir: Path, verbose: bool = True) -> Path:
)
with progress:
task_id = progress.add_task('download', filename=filename, start=False)
logger.info(f'Requesting {url}')
logger.info(f'Requesting {url} to "{dst_path.as_posix()}"')
response = urlopen(url)
# This will break if the response doesn't contain content length
progress.update(task_id, total=int(response.info()['Content-length']))
with open(dst_path, 'wb') as dst_file:
progress.start_task(task_id)
logger.info(f'Downloading to "{dst_path.as_posix()}"')
# logger.info(f'Downloading to "{dst_path.as_posix()}"')
for data in iter(partial(response.read, 32768), b''):
dst_file.write(data)
progress.update(task_id, advance=len(data))
logger.info(f'Downloaded "{dst_path.as_posix()}"')

except KeyboardInterrupt:
logger.info('[red]Cancelling download...')
logger.info('[red]Deleting incomplete download...')
logger.info('[red]Cancelling download...[/red]')
logger.info('[red]Deleting incomplete download...[/red]')
dst_path.unlink(missing_ok=True)
exit(1)

return dst_path


if __name__ == '__main__':
# Try with https://releases.ubuntu.com/20.04/ubuntu-20.04.6-desktop-amd64.iso
import sys

if sys.argv[1:]:
download(sys.argv[-1], './')
else:
print('Usage:\n\tpython downloader.py URL1 URL2 URL3 (etc)')
url = 'https://releases.ubuntu.com/20.04/ubuntu-20.04.6-desktop-amd64.iso'
download(url, './')
8 changes: 8 additions & 0 deletions xrfeitoria/utils/plugin_infos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"0.5.0":
{
"XRFeitoria": "0.5.0",
"XRFeitoriaBpy": "0.5.0",
"XRFeitoriaUnreal": "0.5.0"
}
}
Loading
Loading