浏览代码

Automate meta file check (#2133)

* Script to validate .meta files are set up correctly

* Add command to CI

* don't gitignore Gizmos, add .meta

* Move to utils directory
/develop-generalizationTraining-TrainerController
GitHub 6 年前
当前提交
b3432dda
共有 6 个文件被更改,包括 57 次插入1 次删除
  1. 7
      .circleci/config.yml
  2. 1
      .gitignore
  3. 8
      UnitySDK/Assets/Gizmos.meta
  4. 0
      utils/__init__.py
  5. 42
      utils/validate_meta_files.py

7
.circleci/config.yml


black --check ml-agents-envs
black --check gym-unity
- run:
name: Verify there are no hidden/missing metafiles.
# Renaming files or deleting files can leave metafiles behind that makes Unity very unhappy.
command: |
. venv/bin/activate
python utils/validate_meta_files.py
- store_test_results:
path: test-reports

1
.gitignore


/UnitySDK/[Uu]nity[Pp]ackage[Mm]anager/
/UnitySDK/Assets/AssetStoreTools*
/UnitySDK/Assets/Plugins*
/UnitySDK/Assets/Gizmos*
/UnitySDK/Assets/Demonstrations*
# Tensorflow Model Info

8
UnitySDK/Assets/Gizmos.meta


fileFormatVersion: 2
guid: e74b9e5c364014df1a24c696734cc461
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

0
utils/__init__.py

42
utils/validate_meta_files.py


import json
import os
def main():
asset_path = "UnitySDK/Assets"
meta_suffix = ".meta"
python_suffix = ".py"
num_matched = 0
unmatched = set()
for root, dirs, files in os.walk(asset_path):
dirs = set(dirs)
files = set(files)
combined = dirs | files
for f in combined:
if f.endswith(python_suffix):
# Probably this script; skip it
continue
# We expect each non-.meta file to have a .meta file, and each .meta file to have a non-.meta file
if f.endswith(meta_suffix):
expected = f.replace(meta_suffix, "")
else:
expected = f + meta_suffix
if expected not in combined:
unmatched.add(os.path.join(root, f))
else:
num_matched += 1
if unmatched:
raise Exception(f"Mismatch between expected files and their .meta files: {sorted(unmatched)}")
print(f"Found {num_matched} correctly matched files")
if __name__ == "__main__":
main()
正在加载...
取消
保存