-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix bug * update example * format * move render pipe to engine core * bypass the check process * post pull asset * update doc * pull asset * fix pull bug * releases/0.4.0.1 * format * include examples * update wrokflow * 0.4.0.2
- Loading branch information
Showing
17 changed files
with
152 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
/docs/.idea/ | ||
/build/ | ||
/dist/ | ||
**/assets.zip | ||
/documentation/build/ | ||
/metadrive.egg-info/ | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
recursive-include metadrive/assets/ * | ||
recursive-include metadrive/examples/ * | ||
recursive-include metadrive\\assets\\ * | ||
recursive-include metadrive\\examples\\ * | ||
recursive-include metadrive\assets\ * | ||
recursive-include metadrive\examples\ * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import os | ||
import shutil | ||
import urllib.request | ||
import zipfile | ||
import argparse | ||
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) | ||
|
||
|
||
class MyProgressBar(): | ||
def __init__(self): | ||
self.pbar = None | ||
|
||
def __call__(self, block_num, block_size, total_size): | ||
if not self.pbar: | ||
self.pbar = progressbar.ProgressBar(maxval=total_size) | ||
self.pbar.start() | ||
|
||
downloaded = block_num * block_size | ||
if downloaded < total_size: | ||
self.pbar.update(downloaded) | ||
else: | ||
self.pbar.finish() | ||
|
||
|
||
def pull_asset(): | ||
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: | ||
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( | ||
asset_version(), VERSION | ||
) | ||
) | ||
return | ||
else: | ||
if asset_version() != VERSION: | ||
logger.info("Remove existing assets, version: {}..".format(asset_version())) | ||
shutil.rmtree(os.path.join(TARGET_DIR, "assets")) | ||
else: | ||
logger.warning( | ||
"Fail to pull. Assets is already up-to-date, version: {}. MetaDrive version: {}".format( | ||
asset_version(), VERSION | ||
) | ||
) | ||
return | ||
|
||
zip_path = os.path.join(TARGET_DIR, 'assets.zip') | ||
|
||
# Fetch the zip file | ||
logger.info("Pull the assets from {}".format(ASSET_URL)) | ||
urllib.request.urlretrieve(ASSET_URL, zip_path, MyProgressBar()) | ||
|
||
# Extract the zip file to the desired location | ||
with zipfile.ZipFile(zip_path, 'r') as zip_ref: | ||
zip_ref.extractall(TARGET_DIR) | ||
|
||
# Remove the downloaded zip file (optional) | ||
os.remove(zip_path) | ||
logger.info("Successfully download assets, version: {}. MetaDrive version: {}".format(asset_version(), VERSION)) | ||
|
||
|
||
if __name__ == '__main__': | ||
pull_asset() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,11 @@ | ||
VERSION = "0.3.0.1" | ||
import os | ||
|
||
VERSION = "0.4.0.2" | ||
|
||
|
||
def asset_version(): | ||
asset_path = os.path.join(os.path.dirname(__file__), "assets") | ||
asset_version = os.path.join(asset_path, "version.txt") | ||
with open(asset_version, "r") as file: | ||
lines = file.readlines() | ||
return lines[0] |
Oops, something went wrong.