From aa7d10e68ddfb2d310871b95b5d23d47bd4f2834 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 13 Jun 2019 17:36:46 -0700 Subject: [PATCH 1/4] Script to validate .meta files are set up correctly --- UnitySDK/Assets/validate_meta_files.py | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 UnitySDK/Assets/validate_meta_files.py diff --git a/UnitySDK/Assets/validate_meta_files.py b/UnitySDK/Assets/validate_meta_files.py new file mode 100644 index 0000000000..0ea828ee8b --- /dev/null +++ b/UnitySDK/Assets/validate_meta_files.py @@ -0,0 +1,42 @@ +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() \ No newline at end of file From d731e9b54b8fa36c6fc4ff056d9e9df567653fde Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Thu, 13 Jun 2019 17:40:13 -0700 Subject: [PATCH 2/4] Add command to CI --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9f090c3398..3020b73713 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -48,6 +48,12 @@ jobs: 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 UnitySDK/Assets/validate_meta_files.py + - store_test_results: path: test-reports From 14b0ab5ce26d1539992826db21718f095611d396 Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 14 Jun 2019 09:21:45 -0700 Subject: [PATCH 3/4] don't gitignore Gizmos, add .meta --- .gitignore | 1 - UnitySDK/Assets/Gizmos.meta | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 UnitySDK/Assets/Gizmos.meta diff --git a/.gitignore b/.gitignore index 36937e9918..b454d891bd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ /UnitySDK/[Uu]nity[Pp]ackage[Mm]anager/ /UnitySDK/Assets/AssetStoreTools* /UnitySDK/Assets/Plugins* -/UnitySDK/Assets/Gizmos* /UnitySDK/Assets/Demonstrations* # Tensorflow Model Info diff --git a/UnitySDK/Assets/Gizmos.meta b/UnitySDK/Assets/Gizmos.meta new file mode 100644 index 0000000000..5d0f14a77d --- /dev/null +++ b/UnitySDK/Assets/Gizmos.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e74b9e5c364014df1a24c696734cc461 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 22de423314b071352fe5f7e05cbd385b9d0827db Mon Sep 17 00:00:00 2001 From: Chris Elion Date: Fri, 14 Jun 2019 13:02:57 -0700 Subject: [PATCH 4/4] Move to utils directory --- .circleci/config.yml | 5 +++-- utils/__init__.py | 0 {UnitySDK/Assets => utils}/validate_meta_files.py | 0 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 utils/__init__.py rename {UnitySDK/Assets => utils}/validate_meta_files.py (100%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3020b73713..26366aa392 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -49,10 +49,11 @@ jobs: 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. + 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 UnitySDK/Assets/validate_meta_files.py + python utils/validate_meta_files.py - store_test_results: path: test-reports diff --git a/utils/__init__.py b/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/UnitySDK/Assets/validate_meta_files.py b/utils/validate_meta_files.py similarity index 100% rename from UnitySDK/Assets/validate_meta_files.py rename to utils/validate_meta_files.py