Beispiel #1
0
        public async Task <ACADIAHeatMapOutputs> Handler(ACADIAHeatMapInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                // Preload the dependencies (if they exist),
                // so that they are available during model deserialization.
                var asmLocation = this.GetType().Assembly.Location;
                var asmDir      = Path.GetDirectoryName(asmLocation);
                var asmName     = Path.GetFileNameWithoutExtension(asmLocation);
                var depPath     = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

                if (File.Exists(depPath))
                {
                    Console.WriteLine($"Loading dependencies from assembly: {depPath}...");
                    Assembly.LoadFrom(depPath);
                    Console.WriteLine("Dependencies assembly loaded.");
                }

                this.store = new S3ModelStore <ACADIAHeatMapInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <ACADIAHeatMapInputs, ACADIAHeatMapOutputs>(store, ACADIAHeatMap.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
        public async Task InvokeFunction()
        {
            var root   = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../../");
            var config = Hypar.Functions.Function.FromJson(File.ReadAllText(Path.Combine(root, "hypar.json")));

            var store = new FileModelStore <StructureByEnvelopeInputs>(root, true);

            // Create an input object with default values.
            var input = new StructureByEnvelopeInputs();

            // Read local input files to populate incoming test data.
            if (config.ModelDependencies != null)
            {
                var modelInputKeys = new Dictionary <string, string>();
                foreach (var dep in config.ModelDependencies)
                {
                    modelInputKeys.Add(dep.Name, $"{dep.Name}.json");
                }
                input.ModelInputKeys = modelInputKeys;
            }

            // Invoke the function.
            // The function invocation uses a FileModelStore
            // which will write the resulting model to disk.
            // You'll find the model at "./model.gltf"
            var l = new InvocationWrapper <StructureByEnvelopeInputs, StructureByEnvelopeOutputs>(store, StructureByEnvelope.Execute);
            await l.InvokeAsync(input);
        }
Beispiel #3
0
        public async Task <FoundationByEnvelopeOutputs> Handler(FoundationByEnvelopeInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                this.store = new S3ModelStore <FoundationByEnvelopeInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <FoundationByEnvelopeInputs, FoundationByEnvelopeOutputs>(store, FoundationByEnvelope.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Beispiel #4
0
        public async Task <MakeHyparOutputs> Handler(MakeHyparInputs args, ILambdaContext context)
        {
            if (this.store == null)
            {
                this.store = new S3ModelStore <MakeHyparInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <MakeHyparInputs, MakeHyparOutputs>(store, MakeHypar.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
Beispiel #5
0
        public async Task InvokeFunction()
        {
            var store = new FileModelStore <RefrigeratedLayoutInputs>("./", true);

            // Create an input object with default values.
            var input = new RefrigeratedLayoutInputs();

            // Invoke the function.
            // The function invocation uses a FileModelStore
            // which will write the resulting model to disk.
            // You'll find the model at "./model.gltf"
            var l      = new InvocationWrapper <RefrigeratedLayoutInputs, RefrigeratedLayoutOutputs>(store, RefrigeratedLayout.Execute);
            var output = await l.InvokeAsync(input);
        }
Beispiel #6
0
        public async Task <WallsOutputs> Handler(WallsInputs args, ILambdaContext context)
        {
            // Preload dependencies (if they exist),
            // so that they are available during model deserialization.

            var sw          = System.Diagnostics.Stopwatch.StartNew();
            var asmLocation = this.GetType().Assembly.Location;
            var asmDir      = Path.GetDirectoryName(asmLocation);

            // Explicitly load the dependencies project, it might have types
            // that aren't used in the function but are necessary for correct
            // deserialization.
            var asmName = Path.GetFileNameWithoutExtension(asmLocation);
            var depPath = Path.Combine(asmDir, $"{asmName}.Dependencies.dll");

            if (File.Exists(depPath))
            {
                Console.WriteLine($"Loading dependencies assembly from: {depPath}...");
                Assembly.LoadFrom(depPath);
                Console.WriteLine("Dependencies assembly loaded.");
            }

            // Load all reference assemblies.
            Console.WriteLine($"Loading all referenced assemblies.");
            foreach (var asm in this.GetType().Assembly.GetReferencedAssemblies())
            {
                try
                {
                    Assembly.Load(asm);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Failed to load {asm.FullName}");
                    Console.WriteLine(e.Message);
                }
            }
            sw.Stop();
            Console.WriteLine($"Time to load assemblies: {sw.Elapsed.TotalSeconds})");

            if (this.store == null)
            {
                this.store = new S3ModelStore <WallsInputs>(RegionEndpoint.USWest1);
            }

            var l      = new InvocationWrapper <WallsInputs, WallsOutputs>(store, Walls.Execute);
            var output = await l.InvokeAsync(args);

            return(output);
        }
        public async Task InvokeFunction()
        {
            var store = new FileModelStore <FacadeByEnvelopeInputs>("./", true);

            // Create an input object with default values.
            var input = new FacadeByEnvelopeInputs();

            // Invoke the function.
            // The function invocation uses a FileModelStore
            // which will write the resulting model to disk.
            // You'll find the model at "./model.gltf"
            var l      = new InvocationWrapper <FacadeByEnvelopeInputs, FacadeByEnvelopeOutputs>(store, FacadeByEnvelope.Execute);
            var output = await l.InvokeAsync(input);

            var json = output.model.ToJson();

            File.WriteAllText("../../../facade.json", json);
        }