Christopher Goy
4 年前
当前提交
fe83633e
共有 5 个文件被更改,包括 180 次插入 和 0 次删除
-
50ml-agents/tests/yamato/yamato_utils.py
-
30.yamato/ml-agents-sample-export.yml
-
68Project/Assets/ML-Agents/Editor/Tests/SampleExporter.cs
-
3Project/Assets/ML-Agents/Editor/Tests/SampleExporter.cs.meta
-
29ml-agents/tests/yamato/sample_curation.py
|
|||
sample_export: |
|||
name: Samples Export 2021.2 |
|||
agent: |
|||
type: Unity::VM |
|||
image: package-ci/ubuntu:stable |
|||
flavor: b1.large |
|||
variables: |
|||
UNITY_VERSION: 2021.2 |
|||
commands: |
|||
- python3 -m pip install pyyaml --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple |
|||
- python3 -m pip install unity-downloader-cli --index-url https://artifactory.prd.it.unity3d.com/artifactory/api/pypi/pypi/simple --upgrade |
|||
- unity-downloader-cli -u 2021.2 -c editor --wait --fast |
|||
- python3 -u -m ml-agents.tests.yamato.sample_curation --scene "Assets/ML-Agents/Examples/Basic/Scenes/Basic.unity" "Assets/ML-Agents/Examples/Match3/Scenes/Match3.unity" "Assets/ML-Agents/Examples/WallJump/Scenes/WallJump.unity" "Assets/ML-Agents/TestScenes/TestCompressedGrid/TestGridCompressed.unity" "Assets/ML-Agents/TestScenes/TestCompressedTexture/TestTextureCompressed.unity" |
|||
triggers: |
|||
cancel_old_ci: true |
|||
expression: | |
|||
(pull_request.target eq "main" OR |
|||
pull_request.target match "release.+") AND |
|||
NOT pull_request.draft AND |
|||
(pull_request.changes.any match "com.unity.ml-agents/**" OR |
|||
pull_request.changes.any match "com.unity.ml-agents.extensions/**" OR |
|||
pull_request.changes.any match ".yamato/ml-agents-sample-export.yml") AND |
|||
NOT pull_request.changes.all match "**/*.md" |
|||
artifacts: |
|||
logs: |
|||
paths: |
|||
- "artifacts/sample_export.txt" |
|||
samples: |
|||
paths: |
|||
- "artifacts/Samples/**" |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.iOS; |
|||
|
|||
namespace Unity.MLAgents |
|||
{ |
|||
public class SampleExporter |
|||
{ |
|||
const string k_OutputCommandLineFlag = "--mlagents-sample-ouput-path"; |
|||
const string k_SceneFlag = "--mlagents-scene-path"; |
|||
|
|||
public static void ExportCuratedSamples() |
|||
{ |
|||
var oldBurst = EditorPrefs.GetBool("BurstCompilation"); |
|||
EditorPrefs.SetBool("BurstCompilation", false); |
|||
try |
|||
{ |
|||
var args = Environment.GetCommandLineArgs(); |
|||
var outputPath = "exported_samples"; |
|||
var scenes = new List<string>(); |
|||
for (var i = 0; i < args.Length - 1; i++) |
|||
{ |
|||
if (args[i] == k_OutputCommandLineFlag) |
|||
{ |
|||
outputPath = args[i + 1]; |
|||
Debug.Log($"Overriding output path to {outputPath}"); |
|||
} |
|||
if (args[i] == k_SceneFlag) |
|||
{ |
|||
scenes.Add(args[i + 1]); |
|||
Debug.Log($"Exporting Scene {scenes.Last()}"); |
|||
} |
|||
} |
|||
|
|||
foreach (var scene in scenes) |
|||
{ |
|||
var assets = new List<string> { scene }; |
|||
var exampleFolderToAdd = Directory.GetParent(Directory.GetParent(scene).FullName).FullName; |
|||
Debug.Log($"Parent of Scene: {exampleFolderToAdd}"); |
|||
if (Directory.Exists(Path.Combine(exampleFolderToAdd, "Scripts"))) |
|||
{ |
|||
exampleFolderToAdd = Path.Combine(exampleFolderToAdd, "Scripts"); |
|||
} |
|||
|
|||
exampleFolderToAdd = exampleFolderToAdd.Substring(exampleFolderToAdd.IndexOf("Assets")); |
|||
foreach (var guid in AssetDatabase.FindAssets("t:Script", new[] { exampleFolderToAdd })) |
|||
{ |
|||
var path = AssetDatabase.GUIDToAssetPath(guid); |
|||
assets.Add(path); |
|||
Debug.Log($"Adding Asset: {path}"); |
|||
} |
|||
AssetDatabase.ExportPackage(assets.ToArray(), Path.GetFileNameWithoutExtension(scene) + ".unitypackage", ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Recurse); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Debug.Log(e); |
|||
EditorApplication.Exit(1); |
|||
} |
|||
EditorPrefs.SetBool("BurstCompilation", oldBurst); |
|||
EditorApplication.Exit(0); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 914d5be190bb435eb11383db3aaf70eb |
|||
timeCreated: 1615161245 |
|
|||
import sys |
|||
import argparse |
|||
|
|||
from .yamato_utils import get_base_path, create_samples |
|||
|
|||
|
|||
def main(scenes): |
|||
base_path = get_base_path() |
|||
print(f"Running in base path {base_path}") |
|||
|
|||
returncode = create_samples( |
|||
scenes, |
|||
base_path, |
|||
log_output_path=None, # Log to stdout so we get timestamps on the logs |
|||
) |
|||
|
|||
if returncode == 0: |
|||
print("Test run SUCCEEDED!") |
|||
else: |
|||
print("Test run FAILED!") |
|||
|
|||
sys.exit(returncode) |
|||
|
|||
|
|||
if __name__ == "__main__": |
|||
parser = argparse.ArgumentParser() |
|||
parser.add_argument("--scene", nargs="+", default=None, required=True) |
|||
args = parser.parse_args() |
|||
main(args.scene) |
撰写
预览
正在加载...
取消
保存
Reference in new issue