Esempio n. 1
0
        public SweepJob(Objective objective, SamplingAlgorithm samplingAlgorithm, BinaryData searchSpace, TrialComponent trial)
        {
            if (objective == null)
            {
                throw new ArgumentNullException(nameof(objective));
            }
            if (samplingAlgorithm == null)
            {
                throw new ArgumentNullException(nameof(samplingAlgorithm));
            }
            if (searchSpace == null)
            {
                throw new ArgumentNullException(nameof(searchSpace));
            }
            if (trial == null)
            {
                throw new ArgumentNullException(nameof(trial));
            }

            Inputs            = new ChangeTrackingDictionary <string, JobInput>();
            Objective         = objective;
            Outputs           = new ChangeTrackingDictionary <string, JobOutput>();
            SamplingAlgorithm = samplingAlgorithm;
            SearchSpace       = searchSpace;
            Trial             = trial;
            JobType           = JobType.Sweep;
        }
Esempio n. 2
0
 internal SweepJob(string description, IDictionary <string, string> properties, IDictionary <string, string> tags, string computeId, string displayName, string experimentName, IdentityConfiguration identity, bool?isArchived, JobType jobType, ScheduleBase schedule, IDictionary <string, JobService> services, JobStatus?status, EarlyTerminationPolicy earlyTermination, IDictionary <string, JobInput> inputs, SweepJobLimits limits, Objective objective, IDictionary <string, JobOutput> outputs, SamplingAlgorithm samplingAlgorithm, BinaryData searchSpace, TrialComponent trial) : base(description, properties, tags, computeId, displayName, experimentName, identity, isArchived, jobType, schedule, services, status)
 {
     EarlyTermination  = earlyTermination;
     Inputs            = inputs;
     Limits            = limits;
     Objective         = objective;
     Outputs           = outputs;
     SamplingAlgorithm = samplingAlgorithm;
     SearchSpace       = searchSpace;
     Trial             = trial;
     JobType           = jobType;
 }
Esempio n. 3
0
        internal static SweepJob DeserializeSweepJob(JsonElement element)
        {
            Optional <EarlyTerminationPolicy>          earlyTermination = default;
            Optional <IDictionary <string, JobInput> > inputs           = default;
            Optional <SweepJobLimits> limits = default;
            Objective objective = default;
            Optional <IDictionary <string, JobOutput> > outputs = default;
            SamplingAlgorithm samplingAlgorithm                   = default;
            BinaryData        searchSpace                         = default;
            TrialComponent    trial                               = default;
            Optional <string> computeId                           = default;
            Optional <string> displayName                         = default;
            Optional <string> experimentName                      = default;
            Optional <IdentityConfiguration> identity             = default;
            Optional <bool>         isArchived                    = default;
            JobType                 jobType                       = default;
            Optional <ScheduleBase> schedule                      = default;
            Optional <IDictionary <string, JobService> > services = default;
            Optional <JobStatus> status                           = default;
            Optional <string>    description                      = default;
            Optional <IDictionary <string, string> > properties   = default;
            Optional <IDictionary <string, string> > tags         = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("earlyTermination"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        earlyTermination = null;
                        continue;
                    }
                    earlyTermination = EarlyTerminationPolicy.DeserializeEarlyTerminationPolicy(property.Value);
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        inputs = null;
                        continue;
                    }
                    Dictionary <string, JobInput> dictionary = new Dictionary <string, JobInput>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, JobInput.DeserializeJobInput(property0.Value));
                        }
                    }
                    inputs = dictionary;
                    continue;
                }
                if (property.NameEquals("limits"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        limits = null;
                        continue;
                    }
                    limits = SweepJobLimits.DeserializeSweepJobLimits(property.Value);
                    continue;
                }
                if (property.NameEquals("objective"))
                {
                    objective = Objective.DeserializeObjective(property.Value);
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        outputs = null;
                        continue;
                    }
                    Dictionary <string, JobOutput> dictionary = new Dictionary <string, JobOutput>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, JobOutput.DeserializeJobOutput(property0.Value));
                        }
                    }
                    outputs = dictionary;
                    continue;
                }
                if (property.NameEquals("samplingAlgorithm"))
                {
                    samplingAlgorithm = SamplingAlgorithm.DeserializeSamplingAlgorithm(property.Value);
                    continue;
                }
                if (property.NameEquals("searchSpace"))
                {
                    searchSpace = BinaryData.FromString(property.Value.GetRawText());
                    continue;
                }
                if (property.NameEquals("trial"))
                {
                    trial = TrialComponent.DeserializeTrialComponent(property.Value);
                    continue;
                }
                if (property.NameEquals("computeId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        computeId = null;
                        continue;
                    }
                    computeId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("displayName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        displayName = null;
                        continue;
                    }
                    displayName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("experimentName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        experimentName = null;
                        continue;
                    }
                    experimentName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("identity"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        identity = null;
                        continue;
                    }
                    identity = IdentityConfiguration.DeserializeIdentityConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("isArchived"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    isArchived = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("jobType"))
                {
                    jobType = new JobType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("schedule"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        schedule = null;
                        continue;
                    }
                    schedule = ScheduleBase.DeserializeScheduleBase(property.Value);
                    continue;
                }
                if (property.NameEquals("services"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        services = null;
                        continue;
                    }
                    Dictionary <string, JobService> dictionary = new Dictionary <string, JobService>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, JobService.DeserializeJobService(property0.Value));
                        }
                    }
                    services = dictionary;
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new JobStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        description = null;
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        properties = null;
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, property0.Value.GetString());
                        }
                    }
                    properties = dictionary;
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        tags = null;
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, property0.Value.GetString());
                        }
                    }
                    tags = dictionary;
                    continue;
                }
            }
            return(new SweepJob(description.Value, Optional.ToDictionary(properties), Optional.ToDictionary(tags), computeId.Value, displayName.Value, experimentName.Value, identity.Value, Optional.ToNullable(isArchived), jobType, schedule.Value, Optional.ToDictionary(services), Optional.ToNullable(status), earlyTermination.Value, Optional.ToDictionary(inputs), limits.Value, objective, Optional.ToDictionary(outputs), samplingAlgorithm, searchSpace, trial));
        }