コード例 #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;
        }
コード例 #2
0
        public void CreateJobTest()
        {
            var recipeOwner = "ladybug-tools";
            var recipeName  = "daylight-factor";
            var recipeApi   = new RecipesApi();
            var rec         = recipeApi.GetRecipeByTag(recipeOwner, recipeName, "latest").Manifest;

            var jobInfo = new JobInfo(rec);

            var model = Path.GetFullPath(@"../../../TestSample/two_rooms.hbjson");

            if (!File.Exists(model))
            {
                throw new ArgumentException("Input doesn't exist");
            }
            jobInfo.AddArgument(new JobPathArgument("model", new ProjectFolder(path: model)));

            jobInfo.SetJobSubFolderPath("round1/test");
            jobInfo.SetJobName("A new daylight simulation");

            // run a job
            var task = jobInfo.RunJobOnCloud(Project, (s) => Console.WriteLine(s));


            //cts.CancelAfter(60000);
            ScheduledJob = task.Result;

            Assert.IsTrue(!string.IsNullOrEmpty(ScheduledJob.CloudJob.Id));
        }
コード例 #3
0
        public void GetRecipeParametersTest()
        {
            var rec = api.GetRecipeByTag("ladybug-tools", "annual-energy-use", "latest").Manifest;

            var inputs = rec.Inputs.OfType <GenericInput>();

            foreach (var item in inputs)
            {
                Console.WriteLine($"{item.Name}: {item.Type}");
            }
            Assert.IsTrue(inputs.Any());
        }
コード例 #4
0
        private static void GetRecipeParameters()
        {
            var api = new RecipesApi();
            //var d = api.ListRecipes(owner: new[] { "ladybug-tools" }.ToList()).Resources.First(_ => _.Name == "annual-energy-use");

            var rec = api.GetRecipeByTag("ladybug-tools", "annual-energy-use", "*").Manifest;
            //var recTag = api.GetRecipeByTag("ladybug-tools", "annual-energy-use", "c2657adb0b13db6cd3ff706d9d6db59b98ef8f994d2809d23c3ed449c19b52ea");

            var inputs     = rec.Inputs.OfType <GenericInput>();
            var ParamNames = inputs.Select(_ => _.Name);

            Console.WriteLine("------------------Getting Recipe Input Params---------------------");
            Console.WriteLine(string.Join("\n", ParamNames));
        }
コード例 #5
0
ファイル: Helper.cs プロジェクト: pollination/csharp-sdk
        public static bool GetRecipeFromRecipeSourceURL(string recipeSource, out RecipeInterface recipe)
        {
            //var recipeSource = this.Run.Job.Source;
            var isRecipe = Helper.GetRecipeFromRecipeSourceURL(recipeSource, out var recOwner, out var recName, out var recVersion);

            if (!isRecipe)
            {
                throw new ArgumentException($"Invalid recipe source URL {recipeSource}.\nThe correct formate should be something like:https://api.staging.pollination.cloud/registries/ladybug-tools/recipe/annual-daylight/0.2.0");
            }
            var recApi = new RecipesApi();

            recipe = recApi.GetRecipeByTag(recOwner, recName, recVersion).Manifest;
            return(recipe != null);
        }
コード例 #6
0
        private static JobInfo CreateJob_DaylightFactor()
        {
            var recipeOwner = "ladybug-tools";
            var recipeName  = "daylight-factor";
            var recipeApi   = new RecipesApi();
            var rec         = recipeApi.GetRecipeByTag(recipeOwner, recipeName, "latest").Manifest;

            var jobInfo = new JobInfo(rec);

            jobInfo.AddArgument(new JobPathArgument("model", new ProjectFolder(path: @"D:\Test\queenbeeTest\model.hbjson")));
            //job.AddArgument(new JobPathArgument("input", new ProjectFolder(path: @"D:\Test\queenbeeTest\inputs.json")));


            return(jobInfo);
        }
コード例 #7
0
        private static JobInfo CreateJob_AnnualDaylight()
        {
            var recipeOwner = "ladybug-tools";
            var recipeName  = "annual-daylight";
            var recipeApi   = new RecipesApi();
            var rec         = recipeApi.GetRecipeByTag(recipeOwner, recipeName, "latest").Manifest;

            var jobInfo = new JobInfo(rec);

            //job.AddArgument(new JobArgument("sensor-grids", "[\"room\"]"));
            jobInfo.AddArgument(new JobPathArgument("model", new ProjectFolder(path: @"D:\Test\queenbeeTest\two_rooms.hbjson")));
            jobInfo.AddArgument(new JobPathArgument("wea", new ProjectFolder(path: @"D:\Test\queenbeeTest\golden_co.wea")));

            return(jobInfo);
        }