public async Task <Dictionary <string, double> > Estimate(string id, IDictionary <string, string> args, Action <string> logger) =>
        await IfReady(async() =>
        {
            var qsim = new ResourcesEstimator();
            qsim.DisableLogToConsole();
            qsim.OnLog += logger;

            var value = await Find(id).RunAsync(qsim, args);

            return(qsim.AsDictionary());
        });
示例#2
0
        /// <summary>
        ///     Given an input representing the name of an operation and a JSON
        ///     serialization of its inputs, returns a task that can be awaited
        ///     on for resource estimates from running that operation.
        /// </summary>
        public async Task<ExecutionResult> RunAsync(string input, IChannel channel)
        {
            var (name, args) = ParseInput(input);

            var symbol = SymbolResolver.Resolve(name) as IQSharpSymbol;
            if (symbol == null) throw new InvalidOperationException($"Invalid operation name: {name}");

            var qsim = new ResourcesEstimator().WithStackTraceDisplay(channel);
            qsim.DisableLogToConsole();

            await symbol.Operation.RunAsync(qsim, args);

            return qsim.Data.ToExecutionResult();
        }
示例#3
0
        /// <summary>
        ///     Given an input representing the name of an operation and a JSON
        ///     serialization of its inputs, returns a task that can be awaited
        ///     on for resource estimates from running that operation.
        /// </summary>
        public async Task <ExecutionResult> RunAsync(string input, IChannel channel)
        {
            var inputParameters = ParseInputParameters(input, firstParameterInferredName: ParameterNameOperationName);

            var name   = inputParameters.DecodeParameter <string>(ParameterNameOperationName);
            var symbol = SymbolResolver.Resolve(name) as IQSharpSymbol;

            if (symbol == null)
            {
                throw new InvalidOperationException($"Invalid operation name: {name}");
            }

            var qsim = new ResourcesEstimator().WithStackTraceDisplay(channel);

            qsim.DisableLogToConsole();

            await symbol.Operation.RunAsync(qsim, inputParameters);

            return(qsim.Data.ToExecutionResult());
        }