code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def reinforcer( project: str, location: str, train_steps: int, accelerator_type: str, accelerator_count: int, large_model_reference: str, reward_model_reference: str, machine_type: str, image_uri: str, inputs_sequence_length: int, targets_sequence_length: int, input_refer...
Trains a model using reinforcement learning. Args: project: Project used to run the job. location: Location used to run the job. input_reference_model_path: Path to the base model to fine tune. input_reward_model_path: Path to the reward model to use during reinforcement learning. input_rew...
reinforcer
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/reinforcer.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/reinforcer.py
Apache-2.0
def pipeline( preference_dataset: str, large_model_reference: str, reward_model_reference: str, reward_model_path: str, machine_type: str, tuning_location: str, accelerator_type: str, accelerator_count: int, reward_model_image_uri: str, comma_separated_candidates_field_names: str...
Trains a reward model. Args: preference_dataset: Cloud storage path to a human preference JSONL dataset used to train a reward model. Each example in a preference dataset must contain `candidate_0` and `candidate_1` fields that contain candidate responses, `choice` that specifies the preferred candidate and eith...
pipeline
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/reward_model_graph.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/reward_model_graph.py
Apache-2.0
def reward_model_trainer( project: str, location: str, train_steps: int, accelerator_type: str, accelerator_count: int, large_model_reference: str, machine_type: str, image_uri: str, inputs_sequence_length: int, targets_sequence_length: int, input_model_path: str, input_d...
Trains a reward model. Args: project: Project used to run the job. location: Location used to run the job. input_model_path: Path to the base model to fine tune. input_dataset_path: Path to dataset to use to train a reward model. eval_dataset_path: Path to eval dataset to use during the reward mo...
reward_model_trainer
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/reward_model_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/reward_model_trainer.py
Apache-2.0
def rlhf_preprocessor( large_model_reference: str, accelerator_type: str, use_test_spec: bool, project: str, location: str, artifact_registry: str, tag: str, gcp_resources: dsl.OutputPath(str), # pytype: disable=invalid-annotation has_tensorboard_id: dsl.OutputPath(bool), # pytype:...
Preprocess RLHF pipeline inputs. Args: large_model_reference: The model for fine tuning. accelerator_type: Specific accelerator type for the job. use_test_spec: Whether to use a lower resource machine for testing. project: Project that contains the artifact registry. location: Region that contain...
rlhf_preprocessor
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/rlhf_preprocessor.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/rlhf_preprocessor.py
Apache-2.0
def supervised_fine_tuner( project: str, location: str, train_steps: int, inputs_sequence_length: int, targets_sequence_length: int, accelerator_type: str, accelerator_count: int, large_model_reference: str, machine_type: str, image_uri: str, input_model_path: str, input_...
Performs supervised fine tuning. Args: project: Project used to run the job. location: Location used to run the job. input_model_path: Path to the base model to fine tune. train_steps: Number of training steps. These are the number of steps on top of any steps used to train the base model. ...
supervised_fine_tuner
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/supervised_fine_tuner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/supervised_fine_tuner.py
Apache-2.0
def refined_upload_llm_model( project: str, location: str, artifact_uri: str, model_reference_name: str, model_display_name: str, regional_endpoint: str, model_resource_name: dsl.OutputPath(str), gcp_resources: dsl.OutputPath(str), encryption_spec_key_name: str = '', upload_model...
Uploads LLM model. Args: project: Name of the GCP project. location: Location for model upload and deployment. artifact_uri: Path to the artifact to upload. model_reference_name: Large model reference name. model_display_name: Name of the model (shown in Model Registry). regional_...
refined_upload_llm_model
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/upload_llm_model.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/upload_llm_model.py
Apache-2.0
def upload_tensorboard_metrics( tensorboard_resource_id: str, experiment_name: str, metrics_directory: dsl.Input[dsl.Artifact], # pytype: disable=unsupported-operands tensorboard_uri: dsl.OutputPath(str), # pytype: disable=invalid-annotation ) -> dsl.ContainerSpec: # fmt: off # pylint: disable=g-d...
Uploads tensorboard metrics. Args: tensorboard_resource_id: TensorBoard resource ID in the form `projects/{project_number}/locations/{location}/tensorboards/{tensorboard_id}`. experiment_name: Name of this tensorboard experiment. Must be unique to a given `projects/{project_number}/locations/{location}/t...
upload_tensorboard_metrics
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/upload_tensorboard_metrics.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/upload_tensorboard_metrics.py
Apache-2.0
def build_payload( *, display_name: str, machine_type: str, image_uri: str, args: List[str], accelerator_type: str = '', accelerator_count: int = 0, encryption_spec_key_name: str = '', labels: Optional[Dict[str, str]] = None, scheduling: Optional[Dict[str, Any]] = None, base_...
Generates payload for a custom training job. Args: display_name: Component display name. Can contain up to 128 UTF-8 characters. machine_type: The type of the machine to provision for the custom job. Must be a valid GCE instance type and compatible with the accelerator type. image_uri: Docker...
build_payload
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/utils.py
Apache-2.0
def get_temp_location() -> str: """Gets a task-specific location to store temporary files.""" return os.path.join( kfp.dsl.PIPELINE_ROOT_PLACEHOLDER, kfp.dsl.PIPELINE_JOB_ID_PLACEHOLDER, kfp.dsl.PIPELINE_TASK_ID_PLACEHOLDER, 'temp', )
Gets a task-specific location to store temporary files.
get_temp_location
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/utils.py
Apache-2.0
def get_default_image_uri( image_name: str, image_name_prefix: Optional[str] = None, ) -> str: """Gets the default image URI for a given image. The URI is resolved using environment variables that define the artifact registry, image name modifications and tag. This method only works for images that are...
Gets the default image URI for a given image. The URI is resolved using environment variables that define the artifact registry, image name modifications and tag. This method only works for images that are not selected dynamically based on accelerator type. This is typically true for CPU-only images. Args: ...
get_default_image_uri
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/utils.py
Apache-2.0
def validate_pipeline( location: str, encryption_spec_key_name: str = '', accelerator_type: str = '', eval_dataset: Optional[str] = None, ) -> NamedTuple('PreprocessedInputs', reward_model_eval_dataset=str): # fmt: off """Validates and preprocesses RLHF pipeline parameters. Args: location: Lo...
Validates and preprocesses RLHF pipeline parameters. Args: location: Location used to run non-tuning components, i.e. components that do not require accelerators. If not specified the location used to run the pipeline will be used. encryption_spec_key_name: If set, CMEK support will be validated....
validate_pipeline
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/llm/validate_pipeline.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/llm/validate_pipeline.py
Apache-2.0
def get_vertex_model( gcp_resources: OutputPath(str), model: Output[VertexModel], model_name: str, model_version: str = '', ): """Gets a model artifact or string inputs to an existing Vertex model. Args: model_name: Vertex model resource name in the format of projects/{project}/locations/...
Gets a model artifact or string inputs to an existing Vertex model. Args: model_name: Vertex model resource name in the format of projects/{project}/locations/{location}/models/{model} or projects/{project}/locations/{location}/models/{model}@{model_version_id or model_version_alias}. model...
get_vertex_model
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model/get_model/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model/get_model/component.py
Apache-2.0
def feature_store_grounding_pipeline( project: str, location: str, input_text_gcs_dir: str, bigquery_bp_input_uri: str, bigquery_bp_output_uri: str, output_text_gcs_dir: str, output_error_file_path: str, model_name: str, generation_threshold_microseconds: str = '0', machine_type:...
The Feature Store grounding pipeline. Args: project: Required. The GCP project that runs the pipeline components. location: Required. The GCP region that runs the pipeline components. input_text_gcs_dir: the GCS directory containing the files to chunk. bigquery_bp_input_uri: The URI to a bigquery tab...
feature_store_grounding_pipeline
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/chunking/feature_store_grounding_pipeline.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/chunking/feature_store_grounding_pipeline.py
Apache-2.0
def dataset_preprocessor_error_analysis( gcp_resources: OutputPath(str), batch_prediction_storage_source: OutputPath(list), model_evaluation_storage_source: OutputPath(list), test_data_items_storage_source: OutputPath(str), training_data_items_storage_source: OutputPath(str), project: str, l...
Preprocesses datasets for Vision Error Analysis pipelines. Args: project: GCP Project ID. location: GCP Region. If not set, defaulted to `us-central1`. test_dataset: A google.VertexDataset artifact of the test dataset. If `test_dataset_storage_source_uris` is also provided, ...
dataset_preprocessor_error_analysis
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/dataset_preprocessor/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/dataset_preprocessor/component.py
Apache-2.0
def error_analysis_annotation( gcp_resources: OutputPath(str), error_analysis_output_uri: OutputPath(str), project: str, embeddings_dir: str, root_dir: str, location: str = 'us-central1', machine_type: str = 'n1-standard-8', num_neighbors: int = 5, encryption_spec_key_name: str = '',...
Computes error analysis annotations from image embeddings. Args: project: GCP Project ID. location: GCP Region. If not set, defaulted to `us-central1`. embeddings_dir: The GCS directory containing embeddings output from the embeddings component. root_dir: The GCS directory for...
error_analysis_annotation
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/error_analysis_annotation/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/error_analysis_annotation/component.py
Apache-2.0
def evaluated_annotation( project: str, predictions_storage_source: Input[Artifact], evaluated_annotation_output_uri: dsl.OutputPath(str), gcp_resources: dsl.OutputPath(str), location: Optional[str] = 'us-central1', ground_truth_storage_source: Optional[str] = '', dataflow_service_account: O...
Computes the Evaluated Annotations of a dataset for a model's prediction results. Predicted labels are categorized into TruePositive(TP) or FalsePositive(FP) or FalseNegative(FN) based on their ground truth annotations. Args: project: GCP Project ID. location: GCP Region. If not set, defaulted to ...
evaluated_annotation
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/evaluated_annotation/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/evaluated_annotation/component.py
Apache-2.0
def feature_attribution_graph_component( # pylint: disable=dangerous-default-value location: str, prediction_type: str, vertex_model: VertexModel, batch_predict_instances_format: str, batch_predict_gcs_destination_output_uri: str, batch_predict_gcs_source_uris: List[str] = [], # pylint: disabl...
A pipeline to compute feature attributions by sampling data for batch explanations. This pipeline guarantees support for AutoML Tabular models that contain a valid explanation_spec. Args: location: The GCP region that runs the pipeline components. prediction_type: The type of prediction the model is to ...
feature_attribution_graph_component
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/feature_attribution/feature_attribution_graph_component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/feature_attribution/feature_attribution_graph_component.py
Apache-2.0
def evaluated_annotation_import( model: Input[VertexModel], evaluated_annotation_output_uri: str, evaluation_importer_gcp_resources: str, gcp_resources: dsl.OutputPath(str), error_analysis_output_uri: Optional[str] = None, ): # fmt: off """Imports evaluated annotations to an existing Vertex mode...
Imports evaluated annotations to an existing Vertex model with ModelService.BatchImportEvaluatedAnnotations. Evaluated Annotation inputs must be provided. ErrorAnalysisAnnotation, EvaluatedAnnotationExplanation are optional. Args: model: Vertex model resource that will be the parent resource of the ...
evaluated_annotation_import
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/import_evaluated_annotation/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/import_evaluated_annotation/component.py
Apache-2.0
def model_name_preprocessor( gcp_resources: OutputPath(str), processed_model_name: OutputPath(str), project: str, location: str, model_name: str, service_account: str = '', ): """Preprocess inputs for text2sql evaluation pipeline. Args: project: Required. The GCP project that runs the...
Preprocess inputs for text2sql evaluation pipeline. Args: project: Required. The GCP project that runs the pipeline component. location: Required. The GCP region that runs the pipeline component. model_name: The Model name used to run evaluation. Must be a publisher Model or a managed Model...
model_name_preprocessor
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/model_name_preprocessor/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/model_name_preprocessor/component.py
Apache-2.0
def evaluation_llm_text2sql_pipeline( model_name: str, evaluation_data_source_path: str, tables_metadata_path: str, prompt_template_path: str = '', sql_dialect: str = 'bigquery', evaluation_method: str = 'parser', project: str = _placeholders.PROJECT_ID_PLACEHOLDER, location: str = _plac...
The LLM Evaluation Text2SQL Pipeline. Args: model_name: The Model used to run text2sql evaluation. Must be a frist party publisher model. Supported model names are code-bison, code-gecko, text-bison. evaluation_data_source_path: Required. The path for json file containing text2sql evaluatio...
evaluation_llm_text2sql_pipeline
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/text2sql/evaluation_llm_text2sql_pipeline.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/model_evaluation/text2sql/evaluation_llm_text2sql_pipeline.py
Apache-2.0
def dataprep( gcp_resources: dsl.OutputPath(str), dataprep_dir: dsl.Output[dsl.Artifact], # pytype: disable=unsupported-operands backcast_length: int, forecast_length: int, train_end_date: str, n_val_windows: int, n_test_windows: int, test_set_stride: int, model_blocks: str, big...
Runs Dataprep for training and evaluating a STARRY-Net model. Args: gcp_resources: Serialized JSON of ``gcp_resources`` which tracks the CustomJob. dataprep_dir: The gcp bucket path where all dataprep artifacts are saved. backcast_length: The length of the input window to feed into the model....
dataprep
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/dataprep/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/dataprep/component.py
Apache-2.0
def get_training_artifacts( docker_region: str, trainer_dir: dsl.InputPath(), ) -> NamedTuple( 'TrainingArtifacts', image_uri=str, artifact_uri=str, prediction_schema_uri=str, instance_schema_uri=str, ): # fmt: off """Gets the artifact URIs from the training job. Args: docker_regi...
Gets the artifact URIs from the training job. Args: docker_region: The region from which the training docker image is pulled. trainer_dir: The directory where training artifacts where stored. Returns: A NamedTuple containing the image_uri for the prediction server, the artifact_uri with model arti...
get_training_artifacts
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/get_training_artifacts/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/get_training_artifacts/component.py
Apache-2.0
def maybe_set_tfrecord_args( dataprep_previous_run_dir: str, static_covariates: List[str], ) -> NamedTuple( 'TfrecordArgs', static_covariates_vocab_path=str, train_tf_record_patterns=str, val_tf_record_patterns=str, test_tf_record_patterns=str, ): # fmt: off """Creates Trainer TFRecord a...
Creates Trainer TFRecord args if training with TF Records. Args: dataprep_previous_run_dir: The dataprep dir from a previous run. Use this to save time if you've already created TFRecords from your BigQuery dataset with the same dataprep parameters as this run. static_covariates: The static covar...
maybe_set_tfrecord_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/maybe_set_tfrecord_args/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/maybe_set_tfrecord_args/component.py
Apache-2.0
def set_dataprep_args( model_blocks: List[str], ts_identifier_columns: List[str], static_covariate_columns: List[str], csv_data_path: str, previous_run_dir: str, location: str, ) -> NamedTuple( 'DataprepArgs', model_blocks=str, ts_identifier_columns=str, static_covariate_columns=...
Creates Dataprep args. Args: model_blocks: The list of model blocks to use in the order they will appear in the model. Possible values are `cleaning`, `change_point`, `trend`, `hour_of_week`, `day_of_week`, `day_of_year`, `week_of_year`, `month_of_year`, `residual`. ts_identifier_columns: T...
set_dataprep_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_dataprep_args/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_dataprep_args/component.py
Apache-2.0
def set_eval_args( big_query_source: dsl.Input[dsl.Artifact], quantiles: List[float] ) -> NamedTuple( 'EvalArgs', big_query_source=str, forecasting_type=str, quantiles=List[float], prediction_score_column=str, ): # fmt: off """Creates Evaluation args. Args: big_query_source: The BQ Ta...
Creates Evaluation args. Args: big_query_source: The BQ Table containing the test set. quantiles: The quantiles the model was trained to output. Returns: A NamedTuple containing big_query_source as a string, forecasting_type used for evaluation step, quantiles in the format expected by the evaluat...
set_eval_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_eval_args/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_eval_args/component.py
Apache-2.0
def set_test_set( dataprep_dir: dsl.InputPath(), ) -> NamedTuple('TestSetArtifact', uri=str, artifact=dsl.Artifact): # fmt: off """Creates test set artifact. Args: dataprep_dir: The bucket where dataprep artifacts are stored. Returns: The test set dsl.Artifact. """ import os # pylint: disable...
Creates test set artifact. Args: dataprep_dir: The bucket where dataprep artifacts are stored. Returns: The test set dsl.Artifact.
set_test_set
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_test_set/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_test_set/component.py
Apache-2.0
def set_tfrecord_args( dataprep_dir: dsl.InputPath(), static_covariates: List[str], ) -> NamedTuple( 'TfrecordArgs', static_covariates_vocab_path=str, train_tf_record_patterns=str, val_tf_record_patterns=str, test_tf_record_patterns=str, ): # fmt: off """Creates Trainer TFRecord args. ...
Creates Trainer TFRecord args. Args: dataprep_dir: The dataprep directory where dataprep artifacts are stored. static_covariates: The static covariates to train the model with. Returns: A NamedTuple containing the path to the static covariates covabulary, and the tf record patterns for the train, ...
set_tfrecord_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_tfrecord_args/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_tfrecord_args/component.py
Apache-2.0
def set_train_args( quantiles: List[float], model_blocks: List[str], static_covariates: List[str], ) -> NamedTuple( 'TrainArgs', quantiles=str, use_static_covariates=bool, static_covariate_names=str, model_blocks=str, freeze_point_forecasts=bool, ): # fmt: off """Creates Trainer ...
Creates Trainer model args. Args: quantiles: The list of floats representing quantiles. Leave blank if only training to produce point forecasts. model_blocks: The list of model blocks to use in the order they will appear in the model. Possible values are `cleaning`, `change_point`, `trend`, ...
set_train_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_train_args/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/set_train_args/component.py
Apache-2.0
def train( gcp_resources: dsl.OutputPath(str), trainer_dir: dsl.Output[dsl.Artifact], # pytype: disable=unsupported-operands num_epochs: int, backcast_length: int, forecast_length: int, train_end_date: str, csv_data_path: str, csv_static_covariates_path: str, static_covariates_vocab...
Trains a STARRY-Net model. Args: gcp_resources: Serialized JSON of ``gcp_resources`` which tracks the CustomJob. trainer_dir: The gcp bucket path where training artifacts are saved. num_epochs: The number of epochs to train for. backcast_length: The length of the input window to feed into the m...
train
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/train/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/train/component.py
Apache-2.0
def upload_decomposition_plots( project: str, location: str, tensorboard_id: str, display_name: str, trainer_dir: dsl.InputPath(), ) -> dsl.Artifact: # fmt: off """Uploads decomposition plots to Tensorboard. Args: project: The project where the pipeline is run. Defaults to current project...
Uploads decomposition plots to Tensorboard. Args: project: The project where the pipeline is run. Defaults to current project. location: The location where the pipeline components are run. tensorboard_id: The tensorboard instance ID. display_name: The diplay name of the job. trainer_dir: The dire...
upload_decomposition_plots
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/upload_decomposition_plots/component.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/_implementation/starry_net/upload_decomposition_plots/component.py
Apache-2.0
def get_current_namespace(): """Returns current namespace if available, else kubeflow""" try: current_namespace = open( "/var/run/secrets/kubernetes.io/serviceaccount/namespace" ).read() except: current_namespace = "kubeflow" return current_namespace
Returns current namespace if available, else kubeflow
get_current_namespace
python
kubeflow/pipelines
components/kubeflow/pytorch-launcher/sample.py
https://github.com/kubeflow/pipelines/blob/master/components/kubeflow/pytorch-launcher/sample.py
Apache-2.0
def convert_to_onnx_from_pytorch_script_module( model_path: InputPath('PyTorchScriptModule'), converted_model_path: OutputPath('OnnxModel'), list_of_input_shapes: list, ): '''Creates fully-connected network in PyTorch ScriptModule format''' import torch model = torch.jit.load(model_path) exa...
Creates fully-connected network in PyTorch ScriptModule format
convert_to_onnx_from_pytorch_script_module
python
kubeflow/pipelines
components/PyTorch/Convert_to_OnnxModel_from_PyTorchScriptModule/component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/Convert_to_OnnxModel_from_PyTorchScriptModule/component.py
Apache-2.0
def _validate_spec( cls, spec: standard_component_specs, input_dict: dict, output_dict: dict, exec_properties: dict, ): """validate the specifications 'type'. Args: spec: The standard component specifications input_dict : A dictionary ...
validate the specifications 'type'. Args: spec: The standard component specifications input_dict : A dictionary of inputs. ouput-dict : exec_properties : A dict of execution properties.
_validate_spec
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_component.py
Apache-2.0
def _optional_check(cls, actual_value: any, key: str, spec_dict: dict): """Checks for optional specification. Args: actual_value : Value of the dictionary. key: key for the correspondin value. spec_dict : The dict of specification for validation. Returns : ...
Checks for optional specification. Args: actual_value : Value of the dictionary. key: key for the correspondin value. spec_dict : The dict of specification for validation. Returns : is_optional : The optional key. Raises : ValueError :...
_optional_check
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_component.py
Apache-2.0
def _type_check(cls, actual_value, key, spec_dict): """Checks the type of specifactions. Args: actual_value : Value of the dictionary. key: key for the correspondin value. spec_dict : The dict of specification for validation. Raises : TypeError :...
Checks the type of specifactions. Args: actual_value : Value of the dictionary. key: key for the correspondin value. spec_dict : The dict of specification for validation. Raises : TypeError : If key value type does not match expected value type.
_type_check
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_component.py
Apache-2.0
def _log_startup( self, input_dict: dict, output_dict: dict, exec_properties ): """Log inputs, outputs, and executor properties in a standard format.""" class_name = self.__class__.__name__ logging.debug("Starting %s execution.", class_name) logging.debug("Inputs for ...
Log inputs, outputs, and executor properties in a standard format.
_log_startup
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/base/base_executor.py
Apache-2.0
def __init__(self, mar_config: dict, mar_save_path: str = None): """Initializes the Mar Generation class. Args: mar_config: mar configuration dict (type:dict) mar_save_path : the path for saving the mar file (type:str) """ super(MarGeneration, self).__init__() #...
Initializes the Mar Generation class. Args: mar_config: mar configuration dict (type:dict) mar_save_path : the path for saving the mar file (type:str)
__init__
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/component.py
Apache-2.0
def _validate_mar_config_spec( self, spec: standard_component_specs, mar_config: dict ): """Validates mar config dictionary specs type""" for key in mar_config: self._type_check( actual_value=mar_config[key], key=key.lower(), spec_d...
Validates mar config dictionary specs type
_validate_mar_config_spec
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/component.py
Apache-2.0
def get_fn_args(self, input_dict: dict, exec_properties: dict): #pylint: disable=R0201 """Extracts the mar config from the input dict and save path from exec_properties. Args: input_dict : A input dict, Eample : mar config dict exec_properties : A dict of execution prop...
Extracts the mar config from the input dict and save path from exec_properties. Args: input_dict : A input dict, Eample : mar config dict exec_properties : A dict of execution properties for mar saving path Returns: mar_config : the dict of configuration for ...
get_fn_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
Apache-2.0
def _validate_mar_config(self, mar_config): #pylint: disable=R0201 """Validates the mar configuration properties. Args: mar_config : a dict of mar configurations. Raises: ValueError: if the config file or any mandatory arg is empty """ mandatory_args = ...
Validates the mar configuration properties. Args: mar_config : a dict of mar configurations. Raises: ValueError: if the config file or any mandatory arg is empty
_validate_mar_config
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
Apache-2.0
def download_config_properties(self, url): #pylint: disable=R0201 """Downloads the config.properties. Args: url : the path to download the config.properties """ if not os.path.exists(url): try: url = wget.download(url, tempfile.mkdtemp()) ...
Downloads the config.properties. Args: url : the path to download the config.properties
download_config_properties
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
Apache-2.0
def _generate_mar_file( self, mar_config: dict, mar_save_path: str, output_dict: dict ): """Generates the model mar file. Args: mar_config : mar configuration dict mar_save_path : path to save the mar file. output_dict : the output dict for saving the mar...
Generates the model mar file. Args: mar_config : mar configuration dict mar_save_path : path to save the mar file. output_dict : the output dict for saving the mar file. Raises: Exception : If archiver command is unable to create mar in case of ...
_generate_mar_file
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
Apache-2.0
def _save_config_properties( self, mar_config: dict, mar_save_path: str, output_dict: dict ): """Saves the config.properties file where the mar file is generated. Args : mar_config : dict of mar configuration mar_save_path : the location to save the config.properties...
Saves the config.properties file where the mar file is generated. Args : mar_config : dict of mar configuration mar_save_path : the location to save the config.properties output_dict : dict to assign the mar save path.
_save_config_properties
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
Apache-2.0
def Do(self, input_dict: dict, output_dict: dict, exec_properties: dict): """Executes the mar generation process. Args: input_dict : A input dict, including mar config output_dict : exec_properties : A dict of execution properties for mar generation """ ...
Executes the mar generation process. Args: input_dict : A input dict, including mar config output_dict : exec_properties : A dict of execution properties for mar generation
Do
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/mar/executor.py
Apache-2.0
def __init__( self, source: str, bucket_name: str, destination: str, endpoint: str, ): """Initializes the component class. Args: source : the source path of artifacts. bucket_name : minio bucket name. destination : the dest...
Initializes the component class. Args: source : the source path of artifacts. bucket_name : minio bucket name. destination : the destination path in minio endpoint : minio endpoint url.
__init__
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/component.py
Apache-2.0
def _initiate_minio_client(self, minio_config: dict): #pylint: disable=no-self-use """Initializes the minio client. Args: minio_config : a dict for minio configuration. Returns: client : the minio server client """ minio_host = minio_config["HOST"] ...
Initializes the minio client. Args: minio_config : a dict for minio configuration. Returns: client : the minio server client
_initiate_minio_client
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
Apache-2.0
def _read_minio_creds(self, endpoint: str): #pylint: disable=no-self-use """Reads the minio credentials. Args: endpoint : minio endpoint url Raises: ValueError : if minio access key and secret keys are missing Returns: minio_config : a dict for minio...
Reads the minio credentials. Args: endpoint : minio endpoint url Raises: ValueError : if minio access key and secret keys are missing Returns: minio_config : a dict for minio configuration.
_read_minio_creds
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
Apache-2.0
def upload_artifacts_to_minio( #pylint: disable=no-self-use,too-many-arguments self, client: Minio, source: str, destination: str, bucket_name: str, output_dict: dict, ): """Uploads artifacts to minio server. Args: client : Minio client ...
Uploads artifacts to minio server. Args: client : Minio client source : source path of artifacts. destination : destination path of artifacts bucket_name : minio bucket name. output_dict : dict of output containing destination paths, ...
upload_artifacts_to_minio
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
Apache-2.0
def get_fn_args(self, input_dict: dict, exec_properties: dict): #pylint: disable=no-self-use """Extracts the source, bucket_name, folder_name from the input_dict and endpoint from exec_properties. Args: input_dict : a dict of inputs having source, destinatio...
Extracts the source, bucket_name, folder_name from the input_dict and endpoint from exec_properties. Args: input_dict : a dict of inputs having source, destination etc. exec_properties : a dict of execution properties, havi...
get_fn_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
Apache-2.0
def Do(self, input_dict: dict, output_dict: dict, exec_properties: dict): #pylint: disable=too-many-locals """Executes the minio upload process. Args: input_dict : a dict of inputs having source, destination etc. output_dict : dict of output containing destination paths, ...
Executes the minio upload process. Args: input_dict : a dict of inputs having source, destination etc. output_dict : dict of output containing destination paths, source and bucket names exec_properties : a dict of execution properties, ...
Do
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/minio/executor.py
Apache-2.0
def __init__( # pylint: disable=R0913 self, module_file: Optional = None, data_module_file: Optional = None, data_module_args: Optional[Dict] = None, module_file_args: Optional[Dict] = None, trainer_args: Optional[Dict] = None, ): """Initializes the PyTorch L...
Initializes the PyTorch Lightning training process. Args: module_file : Inherit the model class for training. data_module_file : From this the data module class is inherited. data_module_args : The arguments of the data module. module_file_args : The arguments of...
__init__
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/component.py
Apache-2.0
def Do(self, input_dict: dict, output_dict: dict, exec_properties: dict): #pylint: disable=too-many-locals """This function of the Executor invokes the PyTorch Lightning training loop. Args: input_dict : The dictionary of inputs.Example : model file, data module file ...
This function of the Executor invokes the PyTorch Lightning training loop. Args: input_dict : The dictionary of inputs.Example : model file, data module file output_dict : exec_properties : A dict of execution properties includ...
Do
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/executor.py
Apache-2.0
def _get_fn_args( #pylint: disable=no-self-use self, input_dict: dict, output_dict: dict, execution_properties: dict #pylint: disable=unused-argument ): """Gets the input/output/execution properties from the dictionary. Args: input_dict : The dictionary of inputs.Example : ...
Gets the input/output/execution properties from the dictionary. Args: input_dict : The dictionary of inputs.Example : model file, data module file output_dict : exec_properties : A dict of execution properties including dat...
_get_fn_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/generic_executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/generic_executor.py
Apache-2.0
def derive_model_and_data_module_class( #pylint: disable=no-self-use self, module_file: str, data_module_file: str ): """Derives the model file and data modul file. Args : module_file : A model file name (type:str) data_module_file : A data module file name (type:st...
Derives the model file and data modul file. Args : module_file : A model file name (type:str) data_module_file : A data module file name (type:str) Returns : model_class : The model class data_module_class : The data module class. Raises : ...
derive_model_and_data_module_class
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/generic_executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/trainer/generic_executor.py
Apache-2.0
def parse_input_args(input_str: str): """ Utility to parse input string arguments. Returns a dictionary """ output_dict = {} if not input_str: raise ValueError("Empty input string: {}".format(input_str)) key_pairs: list = input_str.split(",") key_pairs = [x.strip() for x in key_pai...
Utility to parse input string arguments. Returns a dictionary
parse_input_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/utils/argument_parsing.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/utils/argument_parsing.py
Apache-2.0
def __init__( # pylint: disable=R0913 self, mlpipeline_ui_metadata=None, mlpipeline_metrics=None, confusion_matrix_dict=None, test_accuracy=None, markdown=None, ): """Initializes the Visualization component. Args: mlpipeline_ui_metadata :...
Initializes the Visualization component. Args: mlpipeline_ui_metadata : path to save ui metadata mlpipeline_metrics : metrics to be uploaded confusion_metrics_dict : dict for the confusion metrics test_accuracy : test accuracy of the model markdown : ...
__init__
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/component.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/component.py
Apache-2.0
def _write_ui_metadata( self, metadata_filepath, metadata_dict, key="outputs" ): """Function to write the metadata to UI.""" if not os.path.exists(metadata_filepath): metadata = {key: [metadata_dict]} else: with open(metadata_filepath) as fp: m...
Function to write the metadata to UI.
_write_ui_metadata
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
Apache-2.0
def _generate_markdown(self, markdown_dict): """Generates a markdown. Args: markdown_dict : dict of markdown specifications """ source_str = json.dumps( markdown_dict["source"], sort_keys=True, indent=4 ) source = f"```json \n {source_str} ```" ...
Generates a markdown. Args: markdown_dict : dict of markdown specifications
_generate_markdown
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
Apache-2.0
def _generate_confusion_matrix_metadata( self, confusion_matrix_path, classes ): """Generates the confusion matrix metadata and writes in ui.""" print("Generating Confusion matrix Metadata") metadata = { "type": "confusion_matrix", "format": "csv", ...
Generates the confusion matrix metadata and writes in ui.
_generate_confusion_matrix_metadata
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
Apache-2.0
def _upload_confusion_matrix_to_minio( self, confusion_matrix_url, confusion_matrix_output_path ): """Uploads the generated confusion matrix to minio""" parse_obj = urlparse(confusion_matrix_url, allow_fragments=False) bucket_name = parse_obj.netloc folder_name = str(parse_ob...
Uploads the generated confusion matrix to minio
_upload_confusion_matrix_to_minio
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
Apache-2.0
def _get_fn_args(self, input_dict: dict, exec_properties: dict): """Extracts the confusion matrix dict, test accuracy, markdown from the input dict and mlpipeline ui metadata & metrics from exec_properties. Args: input_dict : a dictionary of inputs, example: ...
Extracts the confusion matrix dict, test accuracy, markdown from the input dict and mlpipeline ui metadata & metrics from exec_properties. Args: input_dict : a dictionary of inputs, example: confusion matrix dict, markdown exe_properties : a dict of execu...
_get_fn_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
Apache-2.0
def Do(self, input_dict: dict, output_dict: dict, exec_properties: dict): """Executes the visualization process and uploads to minio Args: input_dict : a dictionary of inputs, example: confusion matrix dict, markdown output_dict : exec_prop...
Executes the visualization process and uploads to minio Args: input_dict : a dictionary of inputs, example: confusion matrix dict, markdown output_dict : exec_properties : a dict of execution properties example : mlpipel...
Do
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/pytorch_kfp_components/components/visualization/executor.py
Apache-2.0
def mar_config(): """Fixture - to use mar_config dict across unit tests """ mar_config = { "MODEL_NAME": "iris_classification", "MODEL_FILE": f"{IRIS_DIR}/iris_classification.py", "HANDLER": f"{IRIS_DIR}/iris_handler.py", "SERIALIZED_FILE":...
Fixture - to use mar_config dict across unit tests
mar_config
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def generate_mar_file(config, save_path): """Generates a mar file with proper configs Args: config : mar config dict save_path : mar file save path """ MarGeneration(mar_config=config, mar_save_path=save_path) mar_path = os.path.join(save_path, "iris_classification.mar") config_p...
Generates a mar file with proper configs Args: config : mar config dict save_path : mar file save path
generate_mar_file
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def test_invalid_mar_config_parameter_type(): """Testing mar generation failure with invalid mar configs.""" mar_config = "invalid_mar_config" tmp_dir = tempfile.mkdtemp() exception_msg = re.escape( f"mar_config must be of " f"type <class 'dict'> but received as {type(mar_config)}" ...
Testing mar generation failure with invalid mar configs.
test_invalid_mar_config_parameter_type
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def test_invalid_mar_save_parameter_type(mar_config): """Test mar generation failure with invalid save path. Raises: TypeError: for passing invalid path type """ mar_save_parameter = ["mar_save_path"] exception_msg = re.escape( f"mar_save_path must be of " f"type <class 'str...
Test mar generation failure with invalid save path. Raises: TypeError: for passing invalid path type
test_invalid_mar_save_parameter_type
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def test_invalid_mar_config_parameter_value(): """Test mar generation failure with empty mar config. Raises: ValueError: If mar config is empty. """ mar_config = {} tmp_dir = tempfile.mkdtemp() exception_msg = re.escape( "mar_config is not optional. Received value: {}".format(m...
Test mar generation failure with empty mar config. Raises: ValueError: If mar config is empty.
test_invalid_mar_config_parameter_value
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def test_mar_generation_mandatory_params_missing(mar_config, mandatory_key): """Testing Mar Generation with missing mandatory keys. Args: mandatory_key : mandatory keys in mar config Raises: Exception : when mandatory keys are missing. """ mar_config.pop(mandatory_key) tmp_dir ...
Testing Mar Generation with missing mandatory keys. Args: mandatory_key : mandatory keys in mar config Raises: Exception : when mandatory keys are missing.
test_mar_generation_mandatory_params_missing
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def test_mar_generation_optional_arguments(mar_config, optional_arg): """Tests mar generation with optional arguments. Args: optional_arg : optional args for mar generation """ new_file, filename = tempfile.mkstemp() #pylint: disable=W0612 mar_config[optional_arg] = os.path.join(os.getcwd...
Tests mar generation with optional arguments. Args: optional_arg : optional args for mar generation
test_mar_generation_optional_arguments
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def test_config_prop_invalid_url(mar_config): """Test mar generation with invalid config.properties url.""" config_prop_url = "dummy" mar_config["CONFIG_PROPERTIES"] = "dummy" exception_msg = ( "Unable to download config properties file using url - {}". format(config_prop_url) ) ...
Test mar generation with invalid config.properties url.
test_config_prop_invalid_url
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_mar_generation.py
Apache-2.0
def minio_inputs(): """Sets the minio inputs. Returns: minio_inputs : dict of inputs for minio uploads. """ minio_input = { "bucket_name": "dummy", "source": f"{tmpdir}/dummy.txt", "destination": "dummy.txt", "endpoint": "localhost:9000", } return minio...
Sets the minio inputs. Returns: minio_inputs : dict of inputs for minio uploads.
minio_inputs
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def test_minio_mandatory_param(minio_inputs, key): """Testing for invalid minio mandatory parameters.""" minio_inputs[key] = None expected_exception_msg = ( f"{key} is not optional. Received value: {minio_inputs[key]}") with pytest.raises(ValueError, match=expected_exception_msg): upload...
Testing for invalid minio mandatory parameters.
test_minio_mandatory_param
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def test_missing_access_key(minio_inputs): """Test upload if minio access key is missing.""" os.environ["MINIO_SECRET_KEY"] = "dummy" expected_exception_msg = "Environment variable MINIO_ACCESS_KEY not found" with pytest.raises(ValueError, match=expected_exception_msg): upload_to_minio(minio_inp...
Test upload if minio access key is missing.
test_missing_access_key
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def test_missing_secret_key(minio_inputs): """Test upload if minio secret key is missing.""" os.environ["MINIO_ACCESS_KEY"] = "dummy" expected_exception_msg = "Environment variable MINIO_SECRET_KEY not found" with pytest.raises(ValueError, match=expected_exception_msg): upload_to_minio(minio_inp...
Test upload if minio secret key is missing.
test_missing_secret_key
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def test_unreachable_endpoint(minio_inputs): """Testing unreachable minio endpoint with invalid minio creds.""" os.environ["MINIO_ACCESS_KEY"] = "dummy" os.environ["MINIO_SECRET_KEY"] = "dummy" with pytest.raises(Exception, match="Max retries exceeded with url: "): upload_to_minio(minio_inputs)
Testing unreachable minio endpoint with invalid minio creds.
test_unreachable_endpoint
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def test_minio_upload_file(minio_inputs): """Testing upload of files to minio.""" with mock.patch.object(Executor, "upload_artifacts_to_minio") as client: client.return_value = [] upload_to_minio(minio_inputs) client.asser_called_once()
Testing upload of files to minio.
test_minio_upload_file
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def test_minio_upload_folder(minio_inputs): """Testing upload of folder to minio.""" minio_inputs["source"] = tmpdir with mock.patch.object(Executor, "upload_artifacts_to_minio") as client: client.return_value = [] upload_to_minio(minio_inputs) client.asser_called_once()
Testing upload of folder to minio.
test_minio_upload_folder
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_minio.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_minio.py
Apache-2.0
def invoke_training(trainer_params): # pylint: disable=W0621 """This function invokes the training process.""" trainer = Trainer( module_file=trainer_params["module_file"], data_module_file=trainer_params["data_module_file"], module_file_args=trainer_params["module_file_args"], ...
This function invokes the training process.
invoke_training
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_mandatory_keys_type_check(trainer_params, mandatory_key): """Tests the uncexpected 'type' of mandatory args. Args: mandatory_key : mandatory arguments for inivoking training """ test_input = ["input_path"] trainer_params[mandatory_key] = test_input expected_exception_msg = ( ...
Tests the uncexpected 'type' of mandatory args. Args: mandatory_key : mandatory arguments for inivoking training
test_mandatory_keys_type_check
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_optional_keys_type_check(trainer_params, optional_key): """Tests the unexpected 'type' of optional args. Args: optional_key: optional arguments for invoking training """ test_input = "test_input" trainer_params[optional_key] = test_input expected_exception_msg = ( f"{opt...
Tests the unexpected 'type' of optional args. Args: optional_key: optional arguments for invoking training
test_optional_keys_type_check
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_mandatory_params(trainer_params, input_key): """Test for empty mandatory arguments. Args: input_key: name of the mandatory arg for training """ trainer_params[input_key] = None expected_exception_msg = ( f"{input_key} is not optional. " f"Received value: {trainer_par...
Test for empty mandatory arguments. Args: input_key: name of the mandatory arg for training
test_mandatory_params
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_data_module_args_optional(trainer_params): """Test for empty optional argument : data module args""" trainer_params["data_module_args"] = None invoke_training(trainer_params=trainer_params) assert os.path.exists(DEFAULT_SAVE_PATH) os.remove(DEFAULT_SAVE_PATH)
Test for empty optional argument : data module args
test_data_module_args_optional
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_trainer_args_none(trainer_params): """Test for empty trainer specific arguments.""" trainer_params["trainer_args"] = None expected_exception_msg = r"trainer_args must be a dict" with pytest.raises(TypeError, match=expected_exception_msg): invoke_training(trainer_params=trainer_params)
Test for empty trainer specific arguments.
test_trainer_args_none
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_training_success(trainer_params): """Test the training success case with all required args.""" trainer = invoke_training(trainer_params=trainer_params) assert os.path.exists(DEFAULT_SAVE_PATH) os.remove(DEFAULT_SAVE_PATH) assert hasattr(trainer, "ptl_trainer") assert isinstance( ...
Test the training success case with all required args.
test_training_success
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_training_success_with_custom_model_name(trainer_params): """Test for successful training with custom model name.""" tmp_dir = tempfile.mkdtemp() trainer_params["module_file_args"]["checkpoint_dir"] = tmp_dir trainer_params["module_file_args"]["model_name"] = "iris.pth" invoke_training(train...
Test for successful training with custom model name.
test_training_success_with_custom_model_name
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_training_failure_with_empty_module_file_args(trainer_params): """Test for successful training with empty module file args.""" trainer_params["module_file_args"] = {} exception_msg = "module_file_args is not optional. Received value: {}" with pytest.raises(ValueError, match=exception_msg): ...
Test for successful training with empty module file args.
test_training_failure_with_empty_module_file_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_training_success_with_empty_trainer_args(trainer_params): """Test for successful training with empty trainer args.""" tmp_dir = tempfile.mkdtemp() trainer_params["module_file_args"]["max_epochs"] = 5 trainer_params["module_file_args"]["checkpoint_dir"] = tmp_dir trainer_params["trainer_args...
Test for successful training with empty trainer args.
test_training_success_with_empty_trainer_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_training_success_with_empty_data_module_args(trainer_params): """Test for successful training with empty data module args.""" tmp_dir = tempfile.mkdtemp() trainer_params["module_file_args"]["checkpoint_dir"] = tmp_dir trainer_params["data_module_args"] = None invoke_training(trainer_params=...
Test for successful training with empty data module args.
test_training_success_with_empty_data_module_args
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def test_trainer_output(trainer_params): """Test for successful training with proper saving of training output.""" tmp_dir = tempfile.mkdtemp() trainer_params["module_file_args"]["checkpoint_dir"] = tmp_dir trainer = invoke_training(trainer_params=trainer_params) assert hasattr(trainer, "output_dic...
Test for successful training with proper saving of training output.
test_trainer_output
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_trainer.py
Apache-2.0
def viz_params(): """Setting visualization parameters. Returns: viz_param : dict of visualization parameters. """ markdown_params = { "storage": "dummy-storage", "source": { "dummy_key": "dummy_value" }, } viz_param = { "mlpipeline_ui_metadat...
Setting visualization parameters. Returns: viz_param : dict of visualization parameters.
viz_params
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def confusion_matrix_params(): """Setting the confusion matrix parameters. Returns: confusion_matrix_params : Dict of confusion matrix parmas """ confusion_matrix_param = { "actuals": ["1", "2", "3", "4"], "preds": ["2", "3", "4", "0"], "classes": ["dummy", "dummy"], ...
Setting the confusion matrix parameters. Returns: confusion_matrix_params : Dict of confusion matrix parmas
confusion_matrix_params
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def generate_visualization(viz_params: dict): #pylint: disable=redefined-outer-name """Generates the visualization object. Returns: output_dict : output dict of vizualization obj. """ viz_obj = Visualization( mlpipeline_ui_metadata=viz_params["mlpipeline_ui_metadata"], mlpipeli...
Generates the visualization object. Returns: output_dict : output dict of vizualization obj.
generate_visualization
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_invalid_type_viz_params(viz_params, viz_key): #pylint: disable=redefined-outer-name """Test visualization for invalid parameter type.""" viz_params[viz_key] = "dummy" if viz_key == "test_accuracy": expected_type = "<class 'float'>" else: expected_type = "<class 'dict'>" exp...
Test visualization for invalid parameter type.
test_invalid_type_viz_params
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_invalid_type_metadata_path(viz_params, viz_key): #pylint: disable=redefined-outer-name """Test visualization with invalid metadata path.""" viz_params[viz_key] = ["dummy"] expected_exception_msg = f"{viz_key} must be of type <class 'str'> " \ f"but received as {type(v...
Test visualization with invalid metadata path.
test_invalid_type_metadata_path
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_default_metadata_path(viz_params, viz_key): #pylint: disable=redefined-outer-name """Test visualization with default metadata path.""" viz_params[viz_key] = None expected_output = { "mlpipeline_ui_metadata": "/mlpipeline-ui-metadata.json", "mlpipeline_metrics": "/mlpipeline-metrics...
Test visualization with default metadata path.
test_default_metadata_path
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_custom_metadata_path(viz_params, tmpdir): #pylint: disable=redefined-outer-name """Test visualization with custom metadata path.""" metadata_ui_path = os.path.join(str(tmpdir), "mlpipeline_ui_metadata.json") metadata_metrics_path = os.path.join(str(tmpdir), ...
Test visualization with custom metadata path.
test_custom_metadata_path
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_setting_all_keys_to_none(viz_params): #pylint: disable=redefined-outer-name """Test visialization with all parameters set to None tyoe.""" for key in viz_params.keys(): viz_params[key] = None expected_exception_msg = r"Any one of these keys should be set -" \ ...
Test visialization with all parameters set to None tyoe.
test_setting_all_keys_to_none
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_accuracy_metric(viz_params): #pylint: disable=redefined-outer-name """Test for getting proper accuracy metric.""" output_dict = generate_visualization(viz_params) assert output_dict is not None metadata_metric_file = viz_params["mlpipeline_metrics"] assert os.path.exists(metadata_metric_fi...
Test for getting proper accuracy metric.
test_accuracy_metric
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_markdown_storage_invalid_datatype(viz_params): #pylint: disable=redefined-outer-name """Test for passing invalid markdown storage datatype.""" viz_params["markdown"]["storage"] = ["test"] expected_exception_msg = ( r"storage must be of type <class 'str'> but received as {}".format( ...
Test for passing invalid markdown storage datatype.
test_markdown_storage_invalid_datatype
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0
def test_markdown_source_invalid_datatype(viz_params): #pylint: disable=redefined-outer-name """Test for passing invalid markdown source datatype.""" viz_params["markdown"]["source"] = "test" expected_exception_msg = ( r"source must be of type <class 'dict'> but received as {}".format( ...
Test for passing invalid markdown source datatype.
test_markdown_source_invalid_datatype
python
kubeflow/pipelines
components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
https://github.com/kubeflow/pipelines/blob/master/components/PyTorch/pytorch-kfp-components/tests/test_visualization.py
Apache-2.0