internal static MLAssistConfiguration DeserializeMLAssistConfiguration(JsonElement element)
        {
            Optional <ComputeBinding> inferencingComputeBinding = default;
            Optional <ComputeBinding> trainingComputeBinding    = default;
            Optional <bool>           mlAssistEnabled           = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("inferencingComputeBinding"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    inferencingComputeBinding = ComputeBinding.DeserializeComputeBinding(property.Value);
                    continue;
                }
                if (property.NameEquals("trainingComputeBinding"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    trainingComputeBinding = ComputeBinding.DeserializeComputeBinding(property.Value);
                    continue;
                }
                if (property.NameEquals("mlAssistEnabled"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    mlAssistEnabled = property.Value.GetBoolean();
                    continue;
                }
            }
            return(new MLAssistConfiguration(inferencingComputeBinding.Value, trainingComputeBinding.Value, Optional.ToNullable(mlAssistEnabled)));
        }
        internal static ComputeJobBase DeserializeComputeJobBase(JsonElement element)
        {
            if (element.TryGetProperty("jobType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Command": return(CommandJob.DeserializeCommandJob(element));

                case "Sweep": return(SweepJob.DeserializeSweepJob(element));
                }
            }
            Optional <string>    experimentName = default;
            ComputeBinding       computeBinding = default;
            Optional <JobOutput> output         = default;
            JobType jobType = default;
            Optional <JobBaseInteractionEndpoints> interactionEndpoints = default;
            Optional <string> description = default;
            Optional <IDictionary <string, string> > tags       = default;
            Optional <IDictionary <string, string> > properties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("experimentName"))
                {
                    experimentName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("computeBinding"))
                {
                    computeBinding = ComputeBinding.DeserializeComputeBinding(property.Value);
                    continue;
                }
                if (property.NameEquals("output"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    output = JobOutput.DeserializeJobOutput(property.Value);
                    continue;
                }
                if (property.NameEquals("jobType"))
                {
                    jobType = new JobType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("interactionEndpoints"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value);
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    properties = dictionary;
                    continue;
                }
            }
            return(new ComputeJobBase(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), experimentName.Value, computeBinding, output.Value));
        }
예제 #3
0
        internal static SweepJob DeserializeSweepJob(JsonElement element)
        {
            Optional <JobStatus>                status = default;
            ParameterSamplingConfiguration      parameterSamplingConfiguration = default;
            Optional <TerminationConfiguration> terminationConfiguration       = default;
            EvaluationConfiguration             evaluationConfiguration        = default;
            Optional <TrialComponent>           trialComponent = default;
            Optional <string>    experimentName = default;
            ComputeBinding       computeBinding = default;
            Optional <JobOutput> output         = default;
            JobType jobType = default;
            Optional <JobBaseInteractionEndpoints> interactionEndpoints = default;
            Optional <string> description = default;
            Optional <IDictionary <string, string> > tags       = default;
            Optional <IDictionary <string, string> > properties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new JobStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("parameterSamplingConfiguration"))
                {
                    parameterSamplingConfiguration = ParameterSamplingConfiguration.DeserializeParameterSamplingConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("terminationConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    terminationConfiguration = TerminationConfiguration.DeserializeTerminationConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("evaluationConfiguration"))
                {
                    evaluationConfiguration = EvaluationConfiguration.DeserializeEvaluationConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("trialComponent"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    trialComponent = TrialComponent.DeserializeTrialComponent(property.Value);
                    continue;
                }
                if (property.NameEquals("experimentName"))
                {
                    experimentName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("computeBinding"))
                {
                    computeBinding = ComputeBinding.DeserializeComputeBinding(property.Value);
                    continue;
                }
                if (property.NameEquals("output"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    output = JobOutput.DeserializeJobOutput(property.Value);
                    continue;
                }
                if (property.NameEquals("jobType"))
                {
                    jobType = new JobType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("interactionEndpoints"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value);
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    properties = dictionary;
                    continue;
                }
            }
            return(new SweepJob(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), experimentName.Value, computeBinding, output.Value, Optional.ToNullable(status), parameterSamplingConfiguration, terminationConfiguration.Value, evaluationConfiguration, trialComponent.Value));
        }
        internal static CommandJob DeserializeCommandJob(JsonElement element)
        {
            Optional <JobStatus> status = default;
            Optional <long>      maxRunDurationSeconds = default;
            CodeConfiguration    codeConfiguration     = default;
            Optional <string>    environmentId         = default;
            Optional <IDictionary <string, DataBinding> > dataBindings = default;
            Optional <DistributionConfiguration>          distributionConfiguration = default;
            Optional <string>    experimentName = default;
            ComputeBinding       computeBinding = default;
            Optional <JobOutput> output         = default;
            JobType jobType = default;
            Optional <JobBaseInteractionEndpoints> interactionEndpoints = default;
            Optional <string> description = default;
            Optional <IDictionary <string, string> > tags       = default;
            Optional <IDictionary <string, string> > properties = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new JobStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("maxRunDurationSeconds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    maxRunDurationSeconds = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("codeConfiguration"))
                {
                    codeConfiguration = CodeConfiguration.DeserializeCodeConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("environmentId"))
                {
                    environmentId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("dataBindings"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, DataBinding> dictionary = new Dictionary <string, DataBinding>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, DataBinding.DeserializeDataBinding(property0.Value));
                    }
                    dataBindings = dictionary;
                    continue;
                }
                if (property.NameEquals("distributionConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    distributionConfiguration = DistributionConfiguration.DeserializeDistributionConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("experimentName"))
                {
                    experimentName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("computeBinding"))
                {
                    computeBinding = ComputeBinding.DeserializeComputeBinding(property.Value);
                    continue;
                }
                if (property.NameEquals("output"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    output = JobOutput.DeserializeJobOutput(property.Value);
                    continue;
                }
                if (property.NameEquals("jobType"))
                {
                    jobType = new JobType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("interactionEndpoints"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    interactionEndpoints = JobBaseInteractionEndpoints.DeserializeJobBaseInteractionEndpoints(property.Value);
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    properties = dictionary;
                    continue;
                }
            }
            return(new CommandJob(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), experimentName.Value, computeBinding, output.Value, Optional.ToNullable(status), Optional.ToNullable(maxRunDurationSeconds), codeConfiguration, environmentId.Value, Optional.ToDictionary(dataBindings), distributionConfiguration.Value));
        }