예제 #1
0
 internal ComputeJobBase(JobType jobType, JobBaseInteractionEndpoints interactionEndpoints, string description, IDictionary <string, string> tags, IDictionary <string, string> properties, string experimentName, ComputeBinding computeBinding, JobOutput output) : base(jobType, interactionEndpoints, description, tags, properties)
 {
     ExperimentName = experimentName;
     ComputeBinding = computeBinding;
     Output         = output;
     JobType        = jobType;
 }
예제 #2
0
 internal JobBase(JobType jobType, JobBaseInteractionEndpoints interactionEndpoints, string description, IDictionary <string, string> tags, IDictionary <string, string> properties)
 {
     JobType = jobType;
     InteractionEndpoints = interactionEndpoints;
     Description          = description;
     Tags       = tags;
     Properties = properties;
 }
예제 #3
0
 internal SweepJob(JobType jobType, JobBaseInteractionEndpoints interactionEndpoints, string description, IDictionary <string, string> tags, IDictionary <string, string> properties, string experimentName, ComputeBinding computeBinding, JobOutput output, JobStatus?status, ParameterSamplingConfiguration parameterSamplingConfiguration, TerminationConfiguration terminationConfiguration, EvaluationConfiguration evaluationConfiguration, TrialComponent trialComponent) : base(jobType, interactionEndpoints, description, tags, properties, experimentName, computeBinding, output)
 {
     Status = status;
     ParameterSamplingConfiguration = parameterSamplingConfiguration;
     TerminationConfiguration       = terminationConfiguration;
     EvaluationConfiguration        = evaluationConfiguration;
     TrialComponent = trialComponent;
     JobType        = jobType;
 }
예제 #4
0
 internal CommandJob(JobType jobType, JobBaseInteractionEndpoints interactionEndpoints, string description, IDictionary <string, string> tags, IDictionary <string, string> properties, string experimentName, ComputeBinding computeBinding, JobOutput output, JobStatus?status, long?maxRunDurationSeconds, CodeConfiguration codeConfiguration, string environmentId, IDictionary <string, DataBinding> dataBindings, DistributionConfiguration distributionConfiguration) : base(jobType, interactionEndpoints, description, tags, properties, experimentName, computeBinding, output)
 {
     Status = status;
     MaxRunDurationSeconds     = maxRunDurationSeconds;
     CodeConfiguration         = codeConfiguration;
     EnvironmentId             = environmentId;
     DataBindings              = dataBindings;
     DistributionConfiguration = distributionConfiguration;
     JobType = jobType;
 }
예제 #5
0
 internal LabelingJob(JobType jobType, JobBaseInteractionEndpoints interactionEndpoints, string description, IDictionary <string, string> tags, IDictionary <string, string> properties, IDictionary <string, LabelCategory> labelCategories, LabelingJobInstructions jobInstructions, LabelingDatasetConfiguration datasetConfiguration, MLAssistConfiguration mlAssistConfiguration, LabelingJobMediaProperties labelingJobMediaProperties, Guid?projectId, JobStatus?status, ProgressMetrics progressMetrics, IList <StatusMessage> statusMessages, DateTimeOffset?createdTimeUtc) : base(jobType, interactionEndpoints, description, tags, properties)
 {
     LabelCategories            = labelCategories;
     JobInstructions            = jobInstructions;
     DatasetConfiguration       = datasetConfiguration;
     MlAssistConfiguration      = mlAssistConfiguration;
     LabelingJobMediaProperties = labelingJobMediaProperties;
     ProjectId       = projectId;
     Status          = status;
     ProgressMetrics = progressMetrics;
     StatusMessages  = statusMessages;
     CreatedTimeUtc  = createdTimeUtc;
     JobType         = jobType;
 }
        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));
        }
예제 #7
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 LabelingJob DeserializeLabelingJob(JsonElement element)
        {
            Optional <IDictionary <string, LabelCategory> > labelCategories    = default;
            Optional <LabelingJobInstructions>      jobInstructions            = default;
            Optional <LabelingDatasetConfiguration> datasetConfiguration       = default;
            Optional <MLAssistConfiguration>        mlAssistConfiguration      = default;
            Optional <LabelingJobMediaProperties>   labelingJobMediaProperties = default;
            Optional <Guid>                   projectId       = default;
            Optional <JobStatus>              status          = default;
            Optional <ProgressMetrics>        progressMetrics = default;
            Optional <IList <StatusMessage> > statusMessages  = default;
            Optional <DateTimeOffset>         createdTimeUtc  = 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("labelCategories"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    Dictionary <string, LabelCategory> dictionary = new Dictionary <string, LabelCategory>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, LabelCategory.DeserializeLabelCategory(property0.Value));
                    }
                    labelCategories = dictionary;
                    continue;
                }
                if (property.NameEquals("jobInstructions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    jobInstructions = LabelingJobInstructions.DeserializeLabelingJobInstructions(property.Value);
                    continue;
                }
                if (property.NameEquals("datasetConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    datasetConfiguration = LabelingDatasetConfiguration.DeserializeLabelingDatasetConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("mlAssistConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    mlAssistConfiguration = MLAssistConfiguration.DeserializeMLAssistConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("labelingJobMediaProperties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    labelingJobMediaProperties = LabelingJobMediaProperties.DeserializeLabelingJobMediaProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("projectId"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    projectId = property.Value.GetGuid();
                    continue;
                }
                if (property.NameEquals("status"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    status = new JobStatus(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("progressMetrics"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    progressMetrics = ProgressMetrics.DeserializeProgressMetrics(property.Value);
                    continue;
                }
                if (property.NameEquals("statusMessages"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <StatusMessage> array = new List <StatusMessage>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(StatusMessage.DeserializeStatusMessage(item));
                    }
                    statusMessages = array;
                    continue;
                }
                if (property.NameEquals("createdTimeUtc"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTimeUtc = property.Value.GetDateTimeOffset("O");
                    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 LabelingJob(jobType, interactionEndpoints.Value, description.Value, Optional.ToDictionary(tags), Optional.ToDictionary(properties), Optional.ToDictionary(labelCategories), jobInstructions.Value, datasetConfiguration.Value, mlAssistConfiguration.Value, labelingJobMediaProperties.Value, Optional.ToNullable(projectId), Optional.ToNullable(status), progressMetrics.Value, Optional.ToList(statusMessages), Optional.ToNullable(createdTimeUtc)));
        }
        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));
        }