Exemple #1
0
        private static void GetRecipeParameters()
        {
            var api = new RecipesApi();
            var d   = api.ListRecipes(owner: new[] { "ladybug-tools" }.ToList()).Resources.First(_ => _.Name == "daylight-factor");


            var recTag = api.GetRecipeByTag(d.Owner.Name, d.Name, d.LatestTag);
            //TODO: ask Antoine to fix why Manifest returns Recipe
            var mani = recTag.Manifest;
            //TODO: ask Antoine to fix why Flow returns DAG
            var flow       = mani.Flow.First();
            var inputs     = flow.Inputs;
            var ParamNames = inputs.Parameters.Select(_ => _.Name);

            Console.WriteLine("------------------Getting Recipe Input Params---------------------");
            Console.WriteLine(string.Join("\n", ParamNames));

            var artifactNames = inputs.Artifacts.Select(_ => _.Name);

            Console.WriteLine("------------------Getting Recipe Input artifacts---------------------");
            Console.WriteLine(string.Join("\n", artifactNames));

            //return inputs.ToString();
            //return recipes;
        }
Exemple #2
0
        //private static PrivateUserDto GetUser()
        //{
        //    var api = new UserApi();
        //    //var config = api.Configuration;
        //    var me = api.GetMe();
        //    return me;
        //}

        private static IEnumerable <string> GetRecipes()
        {
            var api     = new RecipesApi();
            var d       = api.ListRecipes(_public: true);
            var recipes = d.Resources.Select(_ => _.Name);

            return(recipes);
        }
Exemple #3
0
        private static void CreateSimulation(ProjectDto project)
        {
            // Get project
            var proj = project;


            //Recipe
            var recipeApi = new RecipesApi();
            // why Recipe returns repository
            RepositoryAbridgedDto recipe = recipeApi.ListRecipes(owner: new[] { "ladybug-tools" }.ToList(), _public: true).Resources.First(_ => _.Name == "daylight-factor");


            // create a recipeSelection
            var rec = new RecipeSelection(recipe.Owner.Name, recipe.Name);

            // Upload artifacts
            var dir = @"C:\Users\mingo\Downloads\Compressed\project_folder\project_folder";
            //UploadDirectory(proj, dir);

            // create a recipe argument
            var arg = new Arguments()
            {
                Parameters = new List <ArgumentParameter>()
                {
                    new ArgumentParameter("radiance-parameters", "-I -ab 1 -h"),
                    new ArgumentParameter("sensor-grid-count", "10")
                },
                Artifacts = new List <ArgumentArtifact>()
                {
                    new ArgumentArtifact("input-grid", new ArtifaceSourcePath("model/grid/room.pts")),
                    new ArgumentArtifact("model", new ArtifaceSourcePath("model/"))
                }
            };

            Console.WriteLine("-------------------Arguments:-------------------------");
            Console.WriteLine(arg.ToJson());


            // create a new Simulation
            var api  = new SimulationsApi();
            var simu = new SubmitSimulationDto(rec, arg);

            var ret = api.CreateSimulation(proj.Owner.Name, proj.Name, simu);

            Console.WriteLine(ret.Id);
            Console.WriteLine(ret.Message);


            // check simulation status
            var done = CheckSimulationStatus(proj, ret.Id.ToString()).Result;

            var outputs = api.GetSimulationLogs(proj.Owner.Name, proj.Name, ret.Id.ToString());

            //return recipes;
        }
        public void ListRecipesTest()
        {
            var response = api.ListRecipes().Resources;

            foreach (var item in response)
            {
                Console.WriteLine($"{item.Owner.Name}/{item.Name}: {item.LatestTag}");
                Assert.IsTrue(item.LatestTag.ToLower() != "latest");
            }
            Assert.IsTrue(response.Any());
        }