Skip to content

Commit

Permalink
Releases/0.4.0.3 (#484)
Browse files Browse the repository at this point in the history
* automatically download asset

* pull asset

* automatically pull asset

* update instruction

* optimize log message
  • Loading branch information
QuanyiLi committed Aug 22, 2023
1 parent ec35a0c commit b39cbce
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 48 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ jobs:
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
Expand All @@ -57,7 +56,6 @@ jobs:
pip install numpy
pip install gym
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
Expand All @@ -77,7 +75,6 @@ jobs:
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
Expand All @@ -97,7 +94,6 @@ jobs:
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
Expand All @@ -117,7 +113,6 @@ jobs:
pip install cython
pip install numpy
pip install -e .
python -m metadrive.pull_asset
pip install pytest
pip install pytest-cov
pip install ray
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ git clone https://github.com/metadriverse/metadrive.git
cd metadrive
pip install -e .

# pull asset
python -m metadrive.pull_asset
```

or

```bash
pip install metadrive-simulator

# pull asset
python -m metadrive.pull_asset
```
*Note that the program is tested on both Linux and Windows. Some control and display issues in MacOS wait to be solved*

Expand Down
3 changes: 0 additions & 3 deletions documentation/source/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ We recommend to use the command following to install::
cd metadrive
pip install -e .

# pull asset
python -m metadrive.pull_asset

To check whether MetaDrive is successfully installed, please run::

python -m metadrive.examples.profile_metadrive
Expand Down
4 changes: 1 addition & 3 deletions metadrive/component/sensors/base_camera.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import logging

import numpy as np

from metadrive.utils.cuda import check_cudart_err
Expand Down Expand Up @@ -41,7 +39,7 @@ def __init__(self, engine, setup_pbr=False, need_cuda=False):
height = self.BUFFER_H
if (width > 100 or height > 100) and not self.enable_cuda:
# Too large height or width will cause corruption in Mac.
logging.warning(
self.logger.warning(
"You may using too large buffer! The height is {}, and width is {}. "
"It may lower the sample efficiency! Considering reduce buffer size or using cuda image by"
" set [image_on_cuda=True].".format(height, width)
Expand Down
8 changes: 4 additions & 4 deletions metadrive/engine/asset_loader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import pathlib
import sys

from metadrive.pull_asset import pull_asset
from metadrive.engine.logger import get_logger
from metadrive.utils.utils import is_win
from metadrive.version import VERSION
Expand All @@ -21,10 +21,10 @@ def init_loader(engine):
"""
Due to the feature of Panda3d, keep reference of loader in static variable
"""
msg = "Assets folder doesn't exist. Download assets by `python -m metadrive.pull_asset`"
msg = "Assets folder doesn't exist. Begin to download assets..."
if not os.path.exists(AssetLoader.asset_path):
AssetLoader.logger.fatal(msg)
raise FileExistsError(msg)
AssetLoader.logger.warning(msg)
pull_asset(False)
else:
if asset_version() != VERSION:
AssetLoader.logger.warning(
Expand Down
10 changes: 5 additions & 5 deletions metadrive/engine/core/image_buffer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging
from metadrive.engine.logger import get_logger
from direct.filter.FilterManager import FilterManager
import panda3d.core as p3d
from simplepbr import _load_shader_str
Expand Down Expand Up @@ -33,7 +33,7 @@ def __init__(
setup_pbr=False,
engine=None
):

self.logger = get_logger(self.__class__.__name__)
self._node_path_list = []

# from metadrive.engine.engine_utils import get_engine
Expand All @@ -44,7 +44,7 @@ def __init__(
)
assert self.CAM_MASK is not None, "Define a camera mask for every image buffer"
except AssertionError:
logging.debug("Cannot create {}".format(self.__class__.__name__))
self.logger.debug("Cannot create {}".format(self.__class__.__name__))
self.buffer = None
self.cam = NodePath(Camera("non-sense camera"))
self._node_path_list.append(self.cam)
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(
self.tonemap_quad.set_shader_input('tex', self.scene_tex)
self.tonemap_quad.set_shader_input('exposure', 1.0)

logging.debug("Load Image Buffer: {}".format(self.__class__.__name__))
self.logger.debug("Load Image Buffer: {}".format(self.__class__.__name__))

def get_image(self):
"""
Expand Down Expand Up @@ -187,7 +187,7 @@ def destroy(self):
clear_node_list(self._node_path_list)

def __del__(self):
logging.debug("{} is destroyed".format(self.__class__.__name__))
self.logger.debug("{} is destroyed".format(self.__class__.__name__))

@classmethod
def update_display_region_size(cls, display_region_size):
Expand Down
20 changes: 11 additions & 9 deletions metadrive/pull_asset.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import argparse
import os
import shutil
import urllib.request
import zipfile
import argparse

import progressbar

from metadrive.constants import VERSION
from metadrive.engine.logger import get_logger
from metadrive.version import asset_version
from metadrive.constants import VERSION
import progressbar

ASSET_URL = "https://github.com/metadriverse/metadrive/releases/download/MetaDrive-{}/assets.zip".format(VERSION)

Expand All @@ -27,15 +29,12 @@ def __call__(self, block_num, block_size, total_size):
self.pbar.finish()


def pull_asset():
def pull_asset(update):
logger = get_logger("Asset", propagate=False)
logger.handlers.pop()
parser = argparse.ArgumentParser()
parser.add_argument("--update", action="store_true", help="Force overwrite the current assets")
args = parser.parse_args()
TARGET_DIR = os.path.join(os.path.dirname(__file__))
if os.path.exists(os.path.join(TARGET_DIR, "assets")):
if not args.update:
if not update:
logger.warning(
"Fail to pull. Assets already exists, version: {}. Expected version: {}. "
"To overwrite existing assets and update, add flag '--update' and rerun this script".format(
Expand Down Expand Up @@ -71,4 +70,7 @@ def pull_asset():


if __name__ == '__main__':
pull_asset()
parser = argparse.ArgumentParser()
parser.add_argument("--update", action="store_true", help="Force overwrite the current assets")
args = parser.parse_args()
pull_asset(args.update)
2 changes: 1 addition & 1 deletion metadrive/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

VERSION = "0.4.0.2"
VERSION = "0.4.0.3"


def asset_version():
Expand Down
30 changes: 16 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,38 +118,40 @@ def is_win():
"""
How to publish to pypi and Draft github Release? Noted by Zhenghao and Quanyi in Dec 27, 2020.
-1. Checkout a new branch from main called releases/x.y.z
0. Checkout a new branch from main called releases/x.y.z
0. Rename VERSION in metadrive/version.py to x.y,z
1. Rename VERSION in metadrive/version.py to x.y,z
1. Revise the version in metadrive/assets/version.txt
2. Revise the version in metadrive/assets/version.txt, and compress the folder into assets.zip
2. Remove old files and ext_modules from setup() to get a clean wheel for all platforms in py3-none-any.wheel
3. commit changes and push this branch to remote
4. Draft a release on github with new version number and upload assets.zip
5. Remove old files and ext_modules from setup() to get a clean wheel for all platforms in py3-none-any.wheel
rm -rf dist/ build/ documentation/build/ metadrive_simulator.egg-info/ docs/build/
3. Rename current version to X.Y.Z.rcA, where A is arbitrary value represent "release candidate A".
6. Rename current version to X.Y.Z.rcA, where A is arbitrary value represent "release candidate A".
This is really important since pypi do not support renaming and re-uploading.
Rename version in metadrive/versions.py
4. Get wheel
7. Get wheel
python setup.py sdist bdist_wheel
5. Upload to test channel
8. Upload to test channel
twine upload --repository testpypi dist/*
6. Test as next line. If failed, change the version name and repeat 1, 2, 3, 4, 5.
9. Test as next line. If failed, change the version name and repeat 1, 2, 3, 4, 5.
pip install --index-url https://test.pypi.org/simple/ metadrive
7. Rename current version to X.Y.Z in setup.py, rerun 1, 3 steps.
10. Rename current version to X.Y.Z in setup.py, rerun 1, 3 steps.
8. Upload to production channel
11. Upload to production channel
twine upload dist/*
9. Draft a release on github with new version number
10. upload the generated .whl file and new assets folder compressed and named to assets.zip
12. Upload the generated .whl file to release files
11. merge this branch into main
13. merge this branch into main
!!!!!!!!!!!!! NOTE: please make sure that unzip assets.zip will generate a folder called assets instead of files
Expand Down

0 comments on commit b39cbce

Please sign in to comment.