public virtual IList <Scalarm.SimulationParams> GetResults(Boolean fetchFailed = false)
        {
            var options = new GetResultsOptions()
            {
                WithStatus = fetchFailed
            };

            return(GetResults(options));
        }
Beispiel #2
0
        /// <summary>
        /// A legacy version of GetExperimentResults function signature - with fetchFailed parameter.
        /// </summary>
        /// <returns>The experiment results.</returns>
        /// <param name="experimentId">Experiment identifier.</param>
        /// <param name="fetchFailed">If set to <c>true</c> fetch information about failed simulation runs.</param>
        public IList <ValuesMap> GetExperimentResults(string experimentId, Boolean fetchFailed = false)
        {
            var options = new GetResultsOptions()
            {
                WithStatus = fetchFailed
            };

            return(GetExperimentResults(experimentId, options));
        }
        public void Run()
        {
            if (ExperimentId == null)
            {
                throw new Exception("ExperimentId not provided to ExampleGetInfo instance");
            }

            var config = Application.ReadConfig("config.json");
            var client = Application.CreateClient(config);

            try
            {
                Experiment experiment = client.GetExperimentById <Experiment>(ExperimentId);

                Console.WriteLine("Got experiment with id: {0}, name: {1}, started at: {2}", experiment.Id, experiment.Name, experiment.StartAt);

                GetResultsOptions resultsOptions = new GetResultsOptions()
                {
                    WithIndex  = true,
                    WithParams = true,
                    WithMoes   = true,
                    WithStatus = true,
                    MinIndex   = 1,
                    MaxIndex   = 1000
                };

                IList <SimulationParams> results = experiment.GetResults(resultsOptions);


                experiment.GetBinaryResults(ResultsSavePath);
                foreach (SimulationParams r in results)
                {
                    int    index = int.Parse(r.Output["simulation_index"].ToString());
                    string path  = String.Format("/tmp/result-{0}.tar.gz", index);
                    Console.WriteLine("Get results for simulation run {0} to: {1}", index, path);
                    experiment.GetSimulationRunBinaryResult(index, path);
                }

                Console.WriteLine("Binary experiment results saved to: {0}", ResultsSavePath);
            }
            catch (RegisterSimulationScenarioException e)
            {
                Console.WriteLine("Registering simulation scenario failed: " + e);
            }
            catch (CreateScenarioException e)
            {
                Console.WriteLine("Creating experiment failed: " + e);
            }
            catch (InvalidResponseException e)
            {
                Console.WriteLine("Invalid response: {0};\n\n{1};\n\n{2}", e.Response.Content, e.Response.ErrorMessage, e.Response.ErrorException);
            }
            catch (ScalarmResourceException <SimulationScenario> e)
            {
                Console.WriteLine("Error getting Scalarm SimulationScenario resource: {0}", e.Resource.ErrorCode);
            }
        }
        // TODO: parse json to resolve types?
        // <summary>
        //  Gets results in form od Dictionary: input parameters -> MoEs
        //  Input parameters and MoEs are in form of dictionaries: id -> value; both keys and values are string!
        // </summary>
        public virtual IList <SimulationParams> GetResults(GetResultsOptions options)
        {
            // TODO: iterate all this experiment's SimulationParams and fill results to outputs

            IList <ValuesMap> results       = Client.GetExperimentResults(this.Id, options);
            IList <string>    parametersIds = InputDefinition.ParametersIdsForCategories(InputSpecification);

            IList <SimulationParams> finalResults = MakeResults(ConvertTypes(results), parametersIds);

            return(finalResults);
        }
Beispiel #5
0
        /// <summary>
        /// Gets the experiment results in csv when additional parameter passed it return info about status and errors.
        /// </summary>
        /// <returns>The experiment results.</returns>
        /// <param name="experimentId">Experiment identifier.</param>
        /// <param name="fetchFailed">If set to <c>true</c> response will have additional 2 columns status and error_reason.</param>
        public IList <ValuesMap> GetExperimentResults(string experimentId, GetResultsOptions options)
        {
            var request = new RestRequest("/experiments/{id}/file_with_configurations", Method.GET);

            request.AddUrlSegment("id", experimentId);
            if (options != null)
            {
                options.AddUrlSegments(request);
            }
            var response = this.Execute(request);

            ValidateResponseStatus(response);

            return(ParseExperimentsConfigurationsCsv(response.Content));
        }