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 _print_debug_rule_status(self, response, last_print=False): """Prints the status of each debug rule. Example of DebugRuleEvaluationStatuses: response['DebugRuleEvaluationStatuses'] = [{ "RuleConfigurationName": "VanishingGradient", ...
Prints the status of each debug rule. Example of DebugRuleEvaluationStatuses: response['DebugRuleEvaluationStatuses'] = [{ "RuleConfigurationName": "VanishingGradient", "RuleEvaluationStatus": "IssuesFound", "StatusDeta...
_print_debug_rule_status
python
kubeflow/pipelines
components/aws/sagemaker/rlestimator/src/sagemaker_rlestimator_component.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/rlestimator/src/sagemaker_rlestimator_component.py
Apache-2.0
def _create_job_request( self, inputs: RoboMakerSimulationJobInputs, outputs: RoboMakerSimulationJobOutputs, ) -> Dict: """ Documentation:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/robomaker.html#RoboMaker.Client.create_simulation_job "...
Documentation:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/robomaker.html#RoboMaker.Client.create_simulation_job
_create_job_request
python
kubeflow/pipelines
components/aws/sagemaker/simulation_job/src/robomaker_simulation_job_component.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/simulation_job/src/robomaker_simulation_job_component.py
Apache-2.0
def _get_job_outputs(self): """Map the S3 outputs of a simulation job to a dictionary object. Returns: dict: A dictionary of output S3 URIs. """ response = self._rm_client.describe_simulation_job(job=self._arn) artifact_uri = f"s3://{response['outputLocation']['s3Buc...
Map the S3 outputs of a simulation job to a dictionary object. Returns: dict: A dictionary of output S3 URIs.
_get_job_outputs
python
kubeflow/pipelines
components/aws/sagemaker/simulation_job/src/robomaker_simulation_job_component.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/simulation_job/src/robomaker_simulation_job_component.py
Apache-2.0
def _create_job_request( self, inputs: RoboMakerSimulationJobBatchInputs, outputs: RoboMakerSimulationJobBatchOutputs, ) -> Dict: """ Documentation:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/robomaker.html#RoboMaker.Client.start_simulation_job_...
Documentation:https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/robomaker.html#RoboMaker.Client.start_simulation_job_batch
_create_job_request
python
kubeflow/pipelines
components/aws/sagemaker/simulation_job_batch/src/robomaker_simulation_job_batch_component.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/simulation_job_batch/src/robomaker_simulation_job_batch_component.py
Apache-2.0
def _get_resource(job_name, plural): """Get the custom resource detail similar to: kubectl describe <resource> JOB_NAME -n NAMESPACE. Returns: None or object: None if the resource doesn't exist in server or there is an error, otherwise the custom object. """ # Instantiate a new clien...
Get the custom resource detail similar to: kubectl describe <resource> JOB_NAME -n NAMESPACE. Returns: None or object: None if the resource doesn't exist in server or there is an error, otherwise the custom object.
_get_resource
python
kubeflow/pipelines
components/aws/sagemaker/tests/integration_tests/utils/ack_utils.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/tests/integration_tests/utils/ack_utils.py
Apache-2.0
def _delete_resource(job_name, plural, wait_periods=10, period_length=20): """Delete the custom resource Returns: True or False: True if the resource is deleted, False if the resource deletion times out """ _api = client.CustomObjectsApi(k8s_client()) namespace = os.environ.get("NAMESPACE") ...
Delete the custom resource Returns: True or False: True if the resource is deleted, False if the resource deletion times out
_delete_resource
python
kubeflow/pipelines
components/aws/sagemaker/tests/integration_tests/utils/ack_utils.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/tests/integration_tests/utils/ack_utils.py
Apache-2.0
def get_artifact_in_minio(workflow_json, step_name, artifact_name, output_dir): """Minio is the S3 style object storage server for K8s. This method parses a pipeline run's workflow json to fetch the output artifact location in Minio server for given step in the pipeline and downloads it. There are two ...
Minio is the S3 style object storage server for K8s. This method parses a pipeline run's workflow json to fetch the output artifact location in Minio server for given step in the pipeline and downloads it. There are two types of nodes in the workflow_json: DAG and pod. DAG corresonds to the whole pipel...
get_artifact_in_minio
python
kubeflow/pipelines
components/aws/sagemaker/tests/integration_tests/utils/minio_utils.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/tests/integration_tests/utils/minio_utils.py
Apache-2.0
def run_predict_mnist(boto3_session, endpoint_name, download_dir): """https://github.com/awslabs/amazon-sagemaker- examples/blob/a8c20eeb72dc7d3e94aaaf28be5bf7d7cd5695cb. /sagemaker-python-sdk/1P_kmeans_lowlevel/kmeans_mnist_lowlevel.ipynb """ # Download and load dataset region = boto3_session....
https://github.com/awslabs/amazon-sagemaker- examples/blob/a8c20eeb72dc7d3e94aaaf28be5bf7d7cd5695cb. /sagemaker-python-sdk/1P_kmeans_lowlevel/kmeans_mnist_lowlevel.ipynb
run_predict_mnist
python
kubeflow/pipelines
components/aws/sagemaker/tests/integration_tests/utils/sagemaker_utils.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/tests/integration_tests/utils/sagemaker_utils.py
Apache-2.0
def read_from_file_in_tar(file_path, file_name="data", decode=True): """Opens a local tarball and reads the contents of the file as specified. Arguments: - file_path: The local path of the tarball file. - file_name: The name of the file inside the tarball to be read. (Default `"data"`) - decode: Ens...
Opens a local tarball and reads the contents of the file as specified. Arguments: - file_path: The local path of the tarball file. - file_name: The name of the file inside the tarball to be read. (Default `"data"`) - decode: Ensures the contents of the file is decoded to type `str`. (Default `True`) ...
read_from_file_in_tar
python
kubeflow/pipelines
components/aws/sagemaker/tests/integration_tests/utils/__init__.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/tests/integration_tests/utils/__init__.py
Apache-2.0
def generate_random_string(length): """Generate a random string with twice the length of input parameter.""" assert isinstance(length, int) return "".join( [random.choice(string.ascii_lowercase) for n in range(length)] + [random.choice(string.digits) for n in range(length)] )
Generate a random string with twice the length of input parameter.
generate_random_string
python
kubeflow/pipelines
components/aws/sagemaker/tests/integration_tests/utils/__init__.py
https://github.com/kubeflow/pipelines/blob/master/components/aws/sagemaker/tests/integration_tests/utils/__init__.py
Apache-2.0
def convert_CatBoostModel_to_AppleCoreMLModel( model_path: InputPath('CatBoostModel'), converted_model_path: OutputPath('AppleCoreMLModel'), ): '''Convert CatBoost model to Apple CoreML format. Args: model_path: Path of a trained model in binary CatBoost model format. converted_model_pa...
Convert CatBoost model to Apple CoreML format. Args: model_path: Path of a trained model in binary CatBoost model format. converted_model_path: Output path for the converted model. Outputs: converted_model: Model in Apple CoreML format. Annotations: author: Alexey Volkov <...
convert_CatBoostModel_to_AppleCoreMLModel
python
kubeflow/pipelines
components/contrib/CatBoost/convert_CatBoostModel_to_AppleCoreMLModel/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/convert_CatBoostModel_to_AppleCoreMLModel/component.py
Apache-2.0
def convert_CatBoostModel_to_ONNX( model_path: InputPath('CatBoostModel'), converted_model_path: OutputPath('ONNX'), ): '''Convert CatBoost model to ONNX format. Args: model_path: Path of a trained model in binary CatBoost model format. converted_model_path: Output path for the converte...
Convert CatBoost model to ONNX format. Args: model_path: Path of a trained model in binary CatBoost model format. converted_model_path: Output path for the converted model. Outputs: converted_model: Model in ONNX format. Annotations: author: Alexey Volkov <alexey.volkov@ar...
convert_CatBoostModel_to_ONNX
python
kubeflow/pipelines
components/contrib/CatBoost/convert_CatBoostModel_to_ONNX/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/convert_CatBoostModel_to_ONNX/component.py
Apache-2.0
def catboost_predict_classes( data_path: InputPath('CSV'), model_path: InputPath('CatBoostModel'), predictions_path: OutputPath(), label_column: int = None, ): '''Predict classes using the CatBoost classifier model. Args: data_path: Path for the data in CSV format. model_path: ...
Predict classes using the CatBoost classifier model. Args: data_path: Path for the data in CSV format. model_path: Path for the trained model in binary CatBoostModel format. label_column: Column containing the label data. predictions_path: Output path for the predictions. Outpu...
catboost_predict_classes
python
kubeflow/pipelines
components/contrib/CatBoost/Predict_classes/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/Predict_classes/from_CSV/component.py
Apache-2.0
def catboost_predict_class_probabilities( data_path: InputPath('CSV'), model_path: InputPath('CatBoostModel'), predictions_path: OutputPath(), label_column: int = None, ): '''Predict class probabilities with a CatBoost model. Args: data_path: Path for the data in CSV format. mo...
Predict class probabilities with a CatBoost model. Args: data_path: Path for the data in CSV format. model_path: Path for the trained model in binary CatBoostModel format. label_column: Column containing the label data. predictions_path: Output path for the predictions. Outputs...
catboost_predict_class_probabilities
python
kubeflow/pipelines
components/contrib/CatBoost/Predict_class_probabilities/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/Predict_class_probabilities/from_CSV/component.py
Apache-2.0
def catboost_predict_values( data_path: InputPath('CSV'), model_path: InputPath('CatBoostModel'), predictions_path: OutputPath(), label_column: int = None, ): '''Predict values with a CatBoost model. Args: data_path: Path for the data in CSV format. model_path: Path for the tra...
Predict values with a CatBoost model. Args: data_path: Path for the data in CSV format. model_path: Path for the trained model in binary CatBoostModel format. label_column: Column containing the label data. predictions_path: Output path for the predictions. Outputs: pre...
catboost_predict_values
python
kubeflow/pipelines
components/contrib/CatBoost/Predict_values/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/Predict_values/from_CSV/component.py
Apache-2.0
def catboost_train_classifier( training_data_path: InputPath('CSV'), model_path: OutputPath('CatBoostModel'), starting_model_path: InputPath('CatBoostModel') = None, label_column: int = 0, loss_function: str = 'Logloss', num_iterations: int = 500, learning_rate: float = None, depth: int...
Train a CatBoost classifier model. Args: training_data_path: Path for the training data in CSV format. model_path: Output path for the trained model in binary CatBoostModel format. starting_model_path: Path for the existing trained model to start from. label_column: Column containin...
catboost_train_classifier
python
kubeflow/pipelines
components/contrib/CatBoost/Train_classifier/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/Train_classifier/from_CSV/component.py
Apache-2.0
def catboost_train_regression( training_data_path: InputPath('CSV'), model_path: OutputPath('CatBoostModel'), starting_model_path: InputPath('CatBoostModel') = None, label_column: int = 0, loss_function: str = 'RMSE', num_iterations: int = 500, learning_rate: float = None, depth: int = ...
Train a CatBoost classifier model. Args: training_data_path: Path for the training data in CSV format. model_path: Output path for the trained model in binary CatBoostModel format. starting_model_path: Path for the existing trained model to start from. label_column: Column containin...
catboost_train_regression
python
kubeflow/pipelines
components/contrib/CatBoost/Train_regression/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/CatBoost/Train_regression/from_CSV/component.py
Apache-2.0
def split_table_into_folds( table_path: InputPath('CSV'), train_1_path: OutputPath('CSV'), train_2_path: OutputPath('CSV'), train_3_path: OutputPath('CSV'), train_4_path: OutputPath('CSV'), train_5_path: OutputPath('CSV'), test_1_path: OutputPath('CSV'), test_2_path: OutputPath('CSV'),...
Splits the data table into the specified number of folds. The data is split into the specified number of folds k (default: 5). Each testing subsample has 1/k fraction of samples. The testing subsamples do not overlap. Each training subsample has (k-1)/k fraction of samples. The train_i subsample is pro...
split_table_into_folds
python
kubeflow/pipelines
components/contrib/dataset_manipulation/split_data_into_folds/in_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/dataset_manipulation/split_data_into_folds/in_CSV/component.py
Apache-2.0
def automl_create_dataset_for_tables( gcp_project_id: str, gcp_region: str, display_name: str, description: str = None, tables_dataset_metadata: dict = {}, retry=None, #=google.api_core.gapic_v1.method.DEFAULT, timeout: float = None, #=google.api_core.gapic_v1.method.DEFAULT, metadata: d...
automl_create_dataset_for_tables creates an empty Dataset for AutoML tables
automl_create_dataset_for_tables
python
kubeflow/pipelines
components/contrib/google-cloud/automl/create_dataset_for_tables/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/automl/create_dataset_for_tables/component.py
Apache-2.0
def automl_deploy_model( model_path: str, ) -> NamedTuple('Outputs', [ ('model_path', str), ]): """Deploys a trained model. Args: model_path: The resource name of the model to export. Format: 'projects/<project>/locations/<location>/models/<model>' Annotations: author: Alexey Volko...
Deploys a trained model. Args: model_path: The resource name of the model to export. Format: 'projects/<project>/locations/<location>/models/<model>' Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
automl_deploy_model
python
kubeflow/pipelines
components/contrib/google-cloud/automl/deploy_model/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/automl/deploy_model/component.py
Apache-2.0
def automl_export_model_to_gcs( model_path: str, gcs_output_uri_prefix: str, model_format: str = 'tf_saved_model', ) -> NamedTuple('Outputs', [ ('model_directory', 'Uri'), ]): """Exports a trained model to a user specified Google Cloud Storage location. Args: model_path: The resource na...
Exports a trained model to a user specified Google Cloud Storage location. Args: model_path: The resource name of the model to export. Format: 'projects/<project>/locations/<location>/models/<model>' gcs_output_uri_prefix: The Google Cloud Storage directory where the model should be written to. Mus...
automl_export_model_to_gcs
python
kubeflow/pipelines
components/contrib/google-cloud/automl/export_model_to_gcs/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/automl/export_model_to_gcs/component.py
Apache-2.0
def automl_create_tables_dataset_from_csv( data_path: InputPath('CSV'), target_column_name: str = None, column_nullability: dict = {}, column_types: dict = {}, gcs_staging_uri: str = None, # Currently AutoML Tables only supports regional buckets in "us-central1". gcp_project_id: str = None, ...
Creates Google Cloud AutoML Tables Dataset from CSV data. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> Args: data_path: Data in CSV format that will be imported to the dataset. target_column_name: Name of the target column for training. column_nullability: Map...
automl_create_tables_dataset_from_csv
python
kubeflow/pipelines
components/contrib/google-cloud/automl/Tables/Create_dataset/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/automl/Tables/Create_dataset/from_CSV/component.py
Apache-2.0
def add_measurement_for_trial_in_gcp_ai_platform_optimizer( trial_name: str, metric_value: float, complete_trial: bool = True, step_count: float = None, gcp_project_id: str = None, gcp_region: str = "us-central1", ) -> NamedTuple('Outputs', [ ("trial_name", list), ("trial", dict), ("...
Add measurement for a trial and check whether to continue. See https://cloud.google.com/ai-platform/optimizer/docs Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> Args: trial_name: Full trial resource name. metric_value: Result of the trial evaluation. step_c...
add_measurement_for_trial_in_gcp_ai_platform_optimizer
python
kubeflow/pipelines
components/contrib/google-cloud/Optimizer/Add_measurement_for_trial/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/Optimizer/Add_measurement_for_trial/component.py
Apache-2.0
def create_study_in_gcp_ai_platform_optimizer( study_id: str, parameter_specs: list, optimization_goal: str = 'MAXIMIZE', metric_specs: list = None, gcp_project_id: str = None, gcp_region: str = "us-central1", ) -> NamedTuple('Outputs', [ ("study_name", str), ]): """Creates a Google Clou...
Creates a Google Cloud AI Plaform Optimizer study. See https://cloud.google.com/ai-platform/optimizer/docs Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> Args: study_id: Name of the study. parameter_specs: List of parameter specs. See https://cloud.google.com/ai-pla...
create_study_in_gcp_ai_platform_optimizer
python
kubeflow/pipelines
components/contrib/google-cloud/Optimizer/Create_study/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/Optimizer/Create_study/component.py
Apache-2.0
def suggest_parameter_sets_from_measurements_using_gcp_ai_platform_optimizer( parameter_specs: list, metrics_for_parameter_sets: list, suggestion_count: int, maximize: bool = False, metric_specs: list = None, gcp_project_id: str = None, gcp_region: str = "us-central1", ) -> NamedTuple('Outpu...
Suggests trials (parameter sets) to evaluate. See https://cloud.google.com/ai-platform/optimizer/docs Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> Args: parameter_specs: List of parameter specs. See https://cloud.google.com/ai-platform/optimizer/docs/reference/rest/v1/pro...
suggest_parameter_sets_from_measurements_using_gcp_ai_platform_optimizer
python
kubeflow/pipelines
components/contrib/google-cloud/Optimizer/Suggest_parameter_sets_based_on_measurements/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/Optimizer/Suggest_parameter_sets_based_on_measurements/component.py
Apache-2.0
def suggest_trials_in_gcp_ai_platform_optimizer( study_name: str, suggestion_count: int, gcp_project_id: str = None, gcp_region: str = "us-central1", ) -> NamedTuple('Outputs', [ ("suggested_trials", list), ]): """Suggests trials (parameter sets) to evaluate. See https://cloud.google.com/ai-...
Suggests trials (parameter sets) to evaluate. See https://cloud.google.com/ai-platform/optimizer/docs Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> Args: study_name: Full resource name of the study. suggestion_count: Number of suggestions to request.
suggest_trials_in_gcp_ai_platform_optimizer
python
kubeflow/pipelines
components/contrib/google-cloud/Optimizer/Suggest_trials/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/google-cloud/Optimizer/Suggest_trials/component.py
Apache-2.0
def validate_csv_using_greatexpectations( csv_path: InputPath(), expectation_suite_path: InputPath(), data_doc_path: OutputPath(), ): """Validate a CSV dataset against a Great Expectations suite and create Data Doc (a validation report). This component fails if validation is not successful. Ann...
Validate a CSV dataset against a Great Expectations suite and create Data Doc (a validation report). This component fails if validation is not successful. Annotations: authors: Yaroslav Beshta <ybeshta@provectus.com>, Anton Kiselev <akiselev@provectus.com> Args: csv_path: Path to the CSV f...
validate_csv_using_greatexpectations
python
kubeflow/pipelines
components/contrib/great-expectations/validate/CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/great-expectations/validate/CSV/component.py
Apache-2.0
def build_dict( key_1: str = None, value_1: dict = None, key_2: str = None, value_2: dict = None, key_3: str = None, value_3: dict = None, key_4: str = None, value_4: dict = None, key_5: str = None, value_5: dict = None, ) -> dict: """Creates a JSON object from multiple key a...
Creates a JSON object from multiple key and value pairs. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
build_dict
python
kubeflow/pipelines
components/contrib/json/Build_dict/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/json/Build_dict/component.py
Apache-2.0
def build_list( item_1: dict = None, item_2: dict = None, item_3: dict = None, item_4: dict = None, item_5: dict = None, ) -> list: """Creates a JSON array from multiple items. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> """ result = [] for item in [it...
Creates a JSON array from multiple items. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
build_list
python
kubeflow/pipelines
components/contrib/json/Build_list/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/json/Build_list/component.py
Apache-2.0
def combine_lists( list_1: list = None, list_2: list = None, list_3: list = None, list_4: list = None, list_5: list = None, ) -> list: """Combines multiple JSON arrays into one. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com> """ result = [] for list in [l...
Combines multiple JSON arrays into one. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
combine_lists
python
kubeflow/pipelines
components/contrib/json/Combine_lists/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/json/Combine_lists/component.py
Apache-2.0
def keras_train_classifier_from_csv( training_features_path: InputPath('CSV'), training_labels_path: InputPath('CSV'), network_json_path: InputPath('KerasModelJson'), model_path: OutputPath('KerasModelHdf5'), loss_name: str = 'categorical_crossentropy', num_classes: int = None, optimizer: st...
Trains classifier model using Keras. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
keras_train_classifier_from_csv
python
kubeflow/pipelines
components/contrib/keras/Train_classifier/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/keras/Train_classifier/from_CSV/component.py
Apache-2.0
def wait_for_condition(self, namespace, name, expected_conditions=[], timeout=datetime.timedelta(days=365), polling_interval=datetime.timedelta(seconds=30), status_callba...
Waits until any of the specified conditions occur. Args: namespace: namespace for the CR. name: Name of the CR. expected_conditions: A list of conditions. Function waits until any of the supplied conditions is reached. timeout: How long to wait for the CR. polling_interval: How...
wait_for_condition
python
kubeflow/pipelines
components/contrib/kubeflow/common/launch_crd.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/common/launch_crd.py
Apache-2.0
def create(self, spec): """Create a CR. Args: spec: The spec for the CR. """ try: # Create a Resource namespace = spec["metadata"].get("namespace", "default") logger.info("Creating %s/%s %s in namespace %s.", self.group, self.plural, spec["metadata"]["name"], namespace) ...
Create a CR. Args: spec: The spec for the CR.
create
python
kubeflow/pipelines
components/contrib/kubeflow/common/launch_crd.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/common/launch_crd.py
Apache-2.0
def is_classification(transformed_data_dir, target): """Whether the scenario is classification (vs regression). Returns: The number of classes if the target represents a classification problem, or None if it does not. """ transformed_metadata = metadata_io.read_metadata( os.path.join(transformed_...
Whether the scenario is classification (vs regression). Returns: The number of classes if the target represents a classification problem, or None if it does not.
is_classification
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def make_tft_input_metadata(schema): """Create tf-transform metadata from given schema.""" tft_schema = {} for col_schema in schema: col_type = col_schema['type'] col_name = col_schema['name'] if col_type == 'NUMBER': tft_schema[col_name] = dataset_schema.ColumnSchema( tf.float32, [],...
Create tf-transform metadata from given schema.
make_tft_input_metadata
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def make_training_input_fn(transformed_data_dir, mode, batch_size, target_name, num_epochs=None): """Creates an input function reading from transformed data. Args: transformed_data_dir: Directory to read transformed data and metadata from. mode: 'train' or 'eval'. batch_size: Batch size. target_name...
Creates an input function reading from transformed data. Args: transformed_data_dir: Directory to read transformed data and metadata from. mode: 'train' or 'eval'. batch_size: Batch size. target_name: name of the target column. num_epochs: number of training data epochs. Returns: The input f...
make_training_input_fn
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def make_serving_input_fn(transformed_data_dir, schema, target_name): """Creates an input function reading from transformed data. Args: transformed_data_dir: Directory to read transformed data and metadata from. schema: the raw data schema. target_name: name of the target column. Returns: The inpu...
Creates an input function reading from transformed data. Args: transformed_data_dir: Directory to read transformed data and metadata from. schema: the raw data schema. target_name: name of the target column. Returns: The input function for serving.
make_serving_input_fn
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def get_vocab_size(transformed_data_dir, feature_name): """Get vocab size of a given text or category column.""" vocab_file = os.path.join(transformed_data_dir, transform_fn_io.TRANSFORM_FN_DIR, 'assets', 'vocab_' + feature_name) ...
Get vocab size of a given text or category column.
get_vocab_size
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def build_feature_columns(schema, transformed_data_dir, target): """Build feature columns that tf.estimator expects.""" feature_columns = [] for entry in schema: name = entry['name'] datatype = entry['type'] if name == target: continue if datatype == 'NUMBER': feature_columns.append(...
Build feature columns that tf.estimator expects.
build_feature_columns
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def get_estimator(schema, transformed_data_dir, target_name, output_dir, hidden_units, optimizer, learning_rate, feature_columns): """Get proper tf.estimator (DNNClassifier or DNNRegressor).""" optimizer = tf.train.AdagradOptimizer(learning_rate) if optimizer == 'Adam': optimizer = tf.train....
Get proper tf.estimator (DNNClassifier or DNNRegressor).
get_estimator
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def eval_input_receiver_fn(tf_transform_dir, schema, target): """Build everything needed for the tf-model-analysis to run the model. Args: tf_transform_dir: directory in which the tf-transform model was written during the preprocessing step. schema: the raw data schema. target: name of the target ...
Build everything needed for the tf-model-analysis to run the model. Args: tf_transform_dir: directory in which the tf-transform model was written during the preprocessing step. schema: the raw data schema. target: name of the target column. Returns: EvalInputReceiver function, which contains: ...
eval_input_receiver_fn
python
kubeflow/pipelines
components/contrib/kubeflow/dnntrainer/src/trainer/task.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/dnntrainer/src/trainer/task.py
Apache-2.0
def submit_api_request(kfs_client, action, name, isvc, namespace=None, watch=False, timeout_seconds=300): """ Creates or updates a Kubernetes custom object. This code is borrowed from the KFServingClient.create/patch methods as using those directly doesn't allow for sending in dic...
Creates or updates a Kubernetes custom object. This code is borrowed from the KFServingClient.create/patch methods as using those directly doesn't allow for sending in dicts as the InferenceService object which is needed for supporting passing in raw InferenceService serialized YAML.
submit_api_request
python
kubeflow/pipelines
components/contrib/kubeflow/kfserving/src/kfservingdeployer.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/kubeflow/kfserving/src/kfservingdeployer.py
Apache-2.0
def aggregate_regression_metrics( metrics_1: dict, metrics_2: dict = None, metrics_3: dict = None, metrics_4: dict = None, metrics_5: dict = None, ) -> NamedTuple('Outputs', [ ('number_of_items', int), ('max_absolute_error', float), ('mean_absolute_error', float), ('mean_squared_erro...
Calculates regression metrics. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
aggregate_regression_metrics
python
kubeflow/pipelines
components/contrib/ml_metrics/Aggregate_regression_metrics/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/ml_metrics/Aggregate_regression_metrics/component.py
Apache-2.0
def calculate_classification_metrics_from_csv( true_values_path: InputPath(), predicted_values_path: InputPath(), sample_weights_path: InputPath() = None, average: str = 'binary' ) -> NamedTuple('Outputs', [ ('f1', float), ('precision', float), ('recall', float), ('accura...
Calculates classification metrics. Annotations: author: Anton Kiselev <akiselev@provectus.com>
calculate_classification_metrics_from_csv
python
kubeflow/pipelines
components/contrib/ml_metrics/Calculate_classification_metrics/from_CSV/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/ml_metrics/Calculate_classification_metrics/from_CSV/component.py
Apache-2.0
def convert_values_to_int(text_path: InputPath('Text'), output_path: OutputPath('Text')): """Returns the number of values in a CSV column.""" import numpy as np result = np.loadtxt(text_path) np.savetxt(output_path, result, fmt='%d')
Returns the number of values in a CSV column.
convert_values_to_int
python
kubeflow/pipelines
components/contrib/ml_metrics/Calculate_classification_metrics/_samples/sample_pipleine.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/ml_metrics/Calculate_classification_metrics/_samples/sample_pipleine.py
Apache-2.0
def Pandas_Transform_DataFrame_in_CSV_format( table_path: InputPath('CSV'), transformed_table_path: OutputPath('CSV'), transform_code: 'PythonCode', ): '''Transform DataFrame loaded from a CSV file. Inputs: table: Table to transform. transform_code: Transformation code. Code is writ...
Transform DataFrame loaded from a CSV file. Inputs: table: Table to transform. transform_code: Transformation code. Code is written in Python and can consist of multiple lines. The DataFrame variable is called "df". Examples: - `df['prod'] = df['X'] * df['Y']` ...
Pandas_Transform_DataFrame_in_CSV_format
python
kubeflow/pipelines
components/contrib/pandas/Transform_DataFrame/in_CSV_format/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/pandas/Transform_DataFrame/in_CSV_format/component.py
Apache-2.0
def xgboost_predict( data_path: InputPath('CSV'), # Also supports LibSVM model_path: InputPath('XGBoostModel'), predictions_path: OutputPath('Predictions'), label_column: int = None, ): '''Make predictions using a trained XGBoost model. Args: data_path: Path for the feature data in CSV...
Make predictions using a trained XGBoost model. Args: data_path: Path for the feature data in CSV format. model_path: Path for the trained model in binary XGBoost format. predictions_path: Output path for the predictions. label_column: Column containing the label data. Annotati...
xgboost_predict
python
kubeflow/pipelines
components/contrib/XGBoost/Predict/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/XGBoost/Predict/component.py
Apache-2.0
def xgboost_train( training_data_path: InputPath('CSV'), # Also supports LibSVM model_path: OutputPath('XGBoostModel'), model_config_path: OutputPath('XGBoostModelConfig'), starting_model_path: InputPath('XGBoostModel') = None, label_column: int = 0, num_iterations: int = 10, booster_param...
Train an XGBoost model. Args: training_data_path: Path for the training data in CSV format. model_path: Output path for the trained model in binary XGBoost format. model_config_path: Output path for the internal parameter configuration of Booster as a JSON string. starting_model_pat...
xgboost_train
python
kubeflow/pipelines
components/contrib/XGBoost/Train/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/XGBoost/Train/component.py
Apache-2.0
def keras_convert_hdf5_model_to_tf_saved_model( model_path: InputPath('KerasModelHdf5'), converted_model_path: OutputPath('TensorflowSavedModel'), ): '''Converts Keras HDF5 model to Tensorflow SavedModel format. Args: model_path: Keras model in HDF5 format. converted_model_path: Keras m...
Converts Keras HDF5 model to Tensorflow SavedModel format. Args: model_path: Keras model in HDF5 format. converted_model_path: Keras model in Tensorflow SavedModel format. Annotations: author: Alexey Volkov <alexey.volkov@ark-kun.com>
keras_convert_hdf5_model_to_tf_saved_model
python
kubeflow/pipelines
components/contrib/_converters/KerasModelHdf5/to_TensorflowSavedModel/component.py
https://github.com/kubeflow/pipelines/blob/master/components/contrib/_converters/KerasModelHdf5/to_TensorflowSavedModel/component.py
Apache-2.0
def get_return_section(component) -> List[str]: """Modifies docstring so that a return section can be treated as an args section, then parses the docstring. """ docstring = inspect.getdoc(component) type_hints = component.__annotations__ if docstring is None: return [] # Returns and Return are the o...
Modifies docstring so that a return section can be treated as an args section, then parses the docstring.
get_return_section
python
kubeflow/pipelines
components/google-cloud/docs/source/conf.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/docs/source/conf.py
Apache-2.0
def build_serverless_customjob_container_spec( *, project: str, location: str, custom_job_payload: Dict[str, Any], gcp_resources: dsl.OutputPath(str), # pytype: disable=invalid-annotation ) -> dsl.ContainerSpec: """Builds a container spec that launches a custom job. Args: project: Project ...
Builds a container spec that launches a custom job. Args: project: Project to run the job in. location: Location to run the job in. custom_job_payload: Payload to pass to the custom job. This dictionary is serialized and passed as the custom job `--payload`. gcp_resources: GCP resources that ca...
build_serverless_customjob_container_spec
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/utils.py
Apache-2.0
def gcpc_output_name_converter( new_name: str, original_name: Optional[str] = None, ) -> Callable[["BaseComponent"], "BaseComponent"]: # pytype: disable=name-error """Replace the output with original_name with a new_name in a component decorated with an @dsl.container_component decorator. Enables authorin...
Replace the output with original_name with a new_name in a component decorated with an @dsl.container_component decorator. Enables authoring components that have an input and output with the same key/name. Args: new_name: The new name for the output. original_name: The original name of the output. Re...
gcpc_output_name_converter
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/utils.py
Apache-2.0
def main(argv): """Main entry. Expected input args are as follows: Project - Required. The project of which the resource will be launched. Region - Required. The region of which the resource will be launched. Type - Required. GCP launcher is a single container. This Enum will specify which reso...
Main entry. Expected input args are as follows: Project - Required. The project of which the resource will be launched. Region - Required. The region of which the resource will be launched. Type - Required. GCP launcher is a single container. This Enum will specify which resource to be launched. ...
main
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/custom_job/launcher.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/custom_job/launcher.py
Apache-2.0
def parse_nested_json_strings(payload): """Parse nested json strings in the payload.""" job_spec = json.loads(payload) # TODO(b/353577594): Nested placeholder fields inside worker_pool_specs are # not parsed correctly in backend. Can remove when fix backend logic. worker_pool_spec = job_spec['job_spec']['wor...
Parse nested json strings in the payload.
parse_nested_json_strings
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/custom_job/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/custom_job/remote_runner.py
Apache-2.0
def _post_resource(self, url: str, post_data: str) -> Dict[str, Any]: """POST a http request. Args: url: The resource url. post_data: The POST data. Returns: Dict of the JSON payload returned in the http response. Raises: RuntimeError: Failed to get or parse the http response....
POST a http request. Args: url: The resource url. post_data: The POST data. Returns: Dict of the JSON payload returned in the http response. Raises: RuntimeError: Failed to get or parse the http response.
_post_resource
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
Apache-2.0
def check_if_job_exists(self) -> Union[Dict[str, Any], None]: """Check if a Dataflow job already exists. Returns: Dict of the Job resource if it exists. For more details, see: https://cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.jobs#Job None if the Job resource does not exis...
Check if a Dataflow job already exists. Returns: Dict of the Job resource if it exists. For more details, see: https://cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.jobs#Job None if the Job resource does not exist. Raises: ValueError: Job resource uri format is invalid....
check_if_job_exists
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
Apache-2.0
def create_job( self, type: str, job_request: Dict[str, Any], ) -> None: """Create a job using a Dataflow Flex Template. Args: type: Job type that is written to gcp_resources. job_request: A json serialized Job resource. For more details, see: https://cloud.google.com/da...
Create a job using a Dataflow Flex Template. Args: type: Job type that is written to gcp_resources. job_request: A json serialized Job resource. For more details, see: https://cloud.google.com/dataflow/docs/reference/rest/v1b3/projects.jobs#Job Raises: RuntimeError: The Job resource ...
create_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
Apache-2.0
def launch_flex_template( type: str, project: str, location: str, payload: str, gcp_resources: str, ) -> None: """Main function for launching a Dataflow Flex Template. Args: type: Job type that is written to gcp_resources. project: Project to launch the job. location: Location to la...
Main function for launching a Dataflow Flex Template. Args: type: Job type that is written to gcp_resources. project: Project to launch the job. location: Location to launch the job. payload: A json serialized Job resource. For more details, see: https://cloud.google.com/dataflow/docs/reference...
launch_flex_template
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/dataflow/flex_template/remote_runner.py
Apache-2.0
def __init__(self, job_type, project, location, gcp_resources): """Initializes a job client and other common attributes.""" self.job_type = job_type self.project = project self.location = location self.gcp_resources = gcp_resources self.client_options = client_options.ClientOptions( api_...
Initializes a job client and other common attributes.
__init__
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/gcp_launcher/job_remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/gcp_launcher/job_remote_runner.py
Apache-2.0
def check_if_job_exists(self) -> Optional[str]: """Check if the job already exists.""" if ( path.exists(self.gcp_resources) and os.stat(self.gcp_resources).st_size != 0 ): with open(self.gcp_resources) as f: serialized_gcp_resources = f.read() job_resources = json_forma...
Check if the job already exists.
check_if_job_exists
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/preview/gcp_launcher/job_remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/preview/gcp_launcher/job_remote_runner.py
Apache-2.0
def update_output_artifact( executor_input: str, target_artifact_name: str, uri: str, metadata: dict = {}, ) -> None: """Updates the output artifact with the new uri and metadata.""" executor_input_json = json.loads(executor_input) executor_output = {'artifacts': {}} for name, artifacts in ( ...
Updates the output artifact with the new uri and metadata.
update_output_artifact
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/utils/artifact_utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/utils/artifact_utils.py
Apache-2.0
def update_output_artifacts( executor_input: str, artifacts: list, ) -> None: """Updates a list of Artifacts to the executor output file.""" executor_input_json = json.loads(executor_input) executor_output = {'artifacts': {}} output_artifacts = executor_input_json.get('outputs', {}).get('artifacts', {})...
Updates a list of Artifacts to the executor output file.
update_output_artifacts
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/utils/artifact_utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/utils/artifact_utils.py
Apache-2.0
def write_customized_error( executor_input: str, error: task_error_pb2.TaskError ): """Writes a TaskError customized by the author of the pipelines to a JSON file ('executor_error.json') in the output directory specified in the executor input. Args: executor_input: JSON string containing executor input dat...
Writes a TaskError customized by the author of the pipelines to a JSON file ('executor_error.json') in the output directory specified in the executor input. Args: executor_input: JSON string containing executor input data. error: TaskError protocol buffer message.
write_customized_error
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/utils/error_surfacing.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/utils/error_surfacing.py
Apache-2.0
def split_args(kwargs: Dict[str, Any]) -> Tuple[Dict[str, Any], Dict[str, Any]]: """Splits args into constructor and method args. Args: kwargs: kwargs with parameter names preprended with init or method Returns: constructor kwargs, method kwargs """ init_args = {} method_args = {} for key, ...
Splits args into constructor and method args. Args: kwargs: kwargs with parameter names preprended with init or method Returns: constructor kwargs, method kwargs
split_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def write_to_artifact(executor_input, text): """Write output to local artifact and metadata path (uses GCSFuse).""" output_artifacts = {} for name, artifacts in ( executor_input.get('outputs', {}).get('artifacts', {}).items() ): artifacts_list = artifacts.get('artifacts') if artifacts_list: ...
Write output to local artifact and metadata path (uses GCSFuse).
write_to_artifact
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def resolve_input_args(value, type_to_resolve): """If this is an input from Pipelines, read it directly from gcs.""" if inspect.isclass(type_to_resolve) and issubclass( type_to_resolve, aiplatform.base.VertexAiResourceNoun ): # Remove '/gcs/' prefix before attempting to remove `aiplatform` prefix if...
If this is an input from Pipelines, read it directly from gcs.
resolve_input_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def resolve_init_args(key, value): """Resolves Metadata/InputPath parameters to resource names.""" if key.endswith('_name'): # Remove '/gcs/' prefix before attempting to remove `aiplatform` prefix if value.startswith(RESOURCE_PREFIX['google_cloud_storage_gcs_fuse']): # not a resource noun, remove the ...
Resolves Metadata/InputPath parameters to resource names.
resolve_init_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def cast(value: str, annotation_type: Type[T]) -> T: """Casts a value to the annotation type. Includes special handling for bools passed as strings. Args: value (str): The value represented as a string. annotation_type (Type[T]): The type to cast the value to. Returns: An instance of annota...
Casts a value to the annotation type. Includes special handling for bools passed as strings. Args: value (str): The value represented as a string. annotation_type (Type[T]): The type to cast the value to. Returns: An instance of annotation_type value.
cast
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def prepare_parameters( kwargs: Dict[str, Any], method: Callable, is_init: bool = False ): """Prepares parameters passed into components before calling SDK. 1. Determines the annotation type that should used with the parameter 2. Reads input values if needed 3. Deserializes those values where appropriate ...
Prepares parameters passed into components before calling SDK. 1. Determines the annotation type that should used with the parameter 2. Reads input values if needed 3. Deserializes those values where appropriate 4. Or casts to the correct type. Args: kwargs (Dict[str, Any]): The kwargs that will be pa...
prepare_parameters
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def attach_system_labels(method_args, cls_name, method_name): """Add or append the system labels to the labels arg.""" if ( cls_name in [ 'ImageDataset', 'TabularDataset', 'TextDataset', 'TimeSeriesDataset', 'VideoDataset', ] and method_name ...
Add or append the system labels to the labels arg.
attach_system_labels
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/remote_runner.py
Apache-2.0
def get_forward_reference( annotation: Any, ) -> Optional[aiplatform.base.VertexAiResourceNoun]: """Resolves forward references to AiPlatform Class.""" def get_aiplatform_class_by_name(_annotation): """Resolves str annotation to AiPlatfrom Class.""" if isinstance(_annotation, str): return getattr...
Resolves forward references to AiPlatform Class.
get_forward_reference
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def get_aiplatform_class_by_name(_annotation): """Resolves str annotation to AiPlatfrom Class.""" if isinstance(_annotation, str): return getattr(aiplatform, _annotation, None)
Resolves str annotation to AiPlatfrom Class.
get_aiplatform_class_by_name
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def resolve_annotation(annotation: Any) -> Any: """Resolves annotation type against a MB SDK type. Use this for Optional, Union, Forward References Args: annotation: Annotation to resolve Returns: Direct annotation """ # handle forward reference string # if this is an Ai Platform resource...
Resolves annotation type against a MB SDK type. Use this for Optional, Union, Forward References Args: annotation: Annotation to resolve Returns: Direct annotation
resolve_annotation
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def is_serializable_to_json(annotation: Any) -> bool: """Checks if the type is serializable. Args: annotation: parameter annotation Returns: True if serializable to json. """ serializable_types = (dict, list, collections.abc.Sequence, Dict, Sequence) return getattr(annotation, '__origin__', No...
Checks if the type is serializable. Args: annotation: parameter annotation Returns: True if serializable to json.
is_serializable_to_json
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def is_mb_sdk_resource_noun_type(mb_sdk_type: Any) -> bool: """Determines if type passed in should be a metadata type. Args: mb_sdk_type: Type to check Returns: True if this is a resource noun """ if inspect.isclass(mb_sdk_type): return issubclass(mb_sdk_type, aiplatform.base.VertexAiResourc...
Determines if type passed in should be a metadata type. Args: mb_sdk_type: Type to check Returns: True if this is a resource noun
is_mb_sdk_resource_noun_type
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def get_proto_plus_deserializer( annotation: Any, ) -> Optional[Callable[..., str]]: """Get deserializer for objects to pass them as strings. Remote runner will deserialize. Args: annotation: parameter annotation Returns: deserializer for annotation type if it's a Proto Plus class """ pro...
Get deserializer for objects to pass them as strings. Remote runner will deserialize. Args: annotation: parameter annotation Returns: deserializer for annotation type if it's a Proto Plus class
get_proto_plus_deserializer
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def get_deserializer(annotation: Any) -> Optional[Callable[..., str]]: """Get deserializer for objects to pass them as strings. Remote runner will deserialize. Args: annotation: parameter annotation Returns: deserializer for annotation type """ proto_plus_deserializer = get_proto_plus_deseria...
Get deserializer for objects to pass them as strings. Remote runner will deserialize. Args: annotation: parameter annotation Returns: deserializer for annotation type
get_deserializer
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/aiplatform/utils.py
Apache-2.0
def main(argv: List[str]): """Main entry. Expected input args are as follows: Project - Required. The project of which the resource will be launched. Region - Required. The region of which the resource will be launched. Type - Required. GCP launcher is a single container. This Enum will specify...
Main entry. Expected input args are as follows: Project - Required. The project of which the resource will be launched. Region - Required. The region of which the resource will be launched. Type - Required. GCP launcher is a single container. This Enum will specify which resource to be launched. ...
main
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/launcher.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/launcher.py
Apache-2.0
def create_payload( project: str, location: str, display_name: Optional[str] = None, prediction_type: str = _CLASSIFICATION, multi_label: bool = False, model_type: str = 'CLOUD', labels: Optional[Dict[str, str]] = None, dataset: Optional[str] = None, disable_early_stopping: bool = Fa...
Creates a AutoML Image Training Job payload.
create_payload
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/remote_runner.py
Apache-2.0
def create_pipeline_with_client( pipeline_client: gapic.PipelineServiceClient, parent, pipeline_spec: Any, ): """Creates a training pipeline with the client.""" created_pipeline = None try: logging.info( 'Creating AutoML Vision training pipeline with sanitized pipeline' ' spec: %s'...
Creates a training pipeline with the client.
create_pipeline_with_client
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/remote_runner.py
Apache-2.0
def get_pipeline_with_client( pipeline_client: gapic.PipelineServiceClient, pipeline_name: str ): """Gets training pipeline state with the client.""" get_automl_vision_training_pipeline = None try: get_automl_vision_training_pipeline = pipeline_client.get_training_pipeline( name=pipeline_name, ...
Gets training pipeline state with the client.
get_pipeline_with_client
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/automl_training_job/image/remote_runner.py
Apache-2.0
def _sanitize_explanation_metadata(job_spec): """If the job_spec contains explanation metadata, convert to ExplanationMetadata for the job client to recognize.""" if ('explanation_spec' in job_spec) and ( 'metadata' in job_spec['explanation_spec'] ): job_spec['explanation_spec']['metadata'] = ( ...
If the job_spec contains explanation metadata, convert to ExplanationMetadata for the job client to recognize.
_sanitize_explanation_metadata
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
Apache-2.0
def _add_bigquery_scheme(job_spec): """Adds bq:// scheme to BQ URIs where the scheme is missing.""" bq_dataset_pattern = re.compile(_BQ_FULL_TABLE_URI_PATTERN) if ( 'input_config' in job_spec and 'bigquery_source' in job_spec['input_config'] and 'input_uri' in job_spec['input_config']['bigquery_...
Adds bq:// scheme to BQ URIs where the scheme is missing.
_add_bigquery_scheme
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
Apache-2.0
def _sanitize_model_parameters(job_spec: Dict[str, Any]) -> Dict[str, Any]: """If the job_spec contains model_parameters dict, convert to google.protobuf.Value for the job client to recognize.""" if 'model_parameters' in job_spec: job_spec['model_parameters'] = json_format.ParseDict( job_spec['model_par...
If the job_spec contains model_parameters dict, convert to google.protobuf.Value for the job client to recognize.
_sanitize_model_parameters
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
Apache-2.0
def sanitize_job_spec(job_spec): """Cleans job spec before calling the Batch Prediction API.""" job_spec = _sanitize_explanation_metadata(job_spec) job_spec = _add_bigquery_scheme(job_spec) job_spec = _sanitize_model_parameters(job_spec) return job_spec
Cleans job spec before calling the Batch Prediction API.
sanitize_job_spec
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/batch_prediction_job/remote_runner.py
Apache-2.0
def bigquery_explain_forecast_model_job( type, project, location, model_name, horizon, confidence_level, payload, job_configuration_query_override, gcp_resources, executor_input, ): """Create and poll bigquery ML.EXPLAIN_FORECAST job till it reaches a final state. The launch...
Create and poll bigquery ML.EXPLAIN_FORECAST job till it reaches a final state. The launching logic is the same as bigquery_{predict|evaluate}_model_job. Args: type: BigQuery ML.EXPLAIN_FORECAST job type. project: Project to launch the query job. location: location to launch the query job. For m...
bigquery_explain_forecast_model_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/explain_forecast_model/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/explain_forecast_model/remote_runner.py
Apache-2.0
def bigquery_forecast_model_job( type, project, location, model_name, horizon, confidence_level, payload, job_configuration_query_override, gcp_resources, executor_input, ): """Create and poll bigquery ML.FORECAST job till it reaches a final state. The launching logic is the...
Create and poll bigquery ML.FORECAST job till it reaches a final state. The launching logic is the same as bigquery_{predict|evaluate}_model_job. Args: type: BigQuery ML.FORECAST job type. project: Project to launch the query job. location: location to launch the query job. For more details, see...
bigquery_forecast_model_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/forecast_model/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/forecast_model/remote_runner.py
Apache-2.0
def bigquery_ml_arima_coefficients( type, project, location, model_name, payload, job_configuration_query_override, gcp_resources, executor_input, ): """Create and poll bigquery ML.ARIMA_COEFFICIENTS job till it reaches a final state. The launching logic is the same as bigquery_{pre...
Create and poll bigquery ML.ARIMA_COEFFICIENTS job till it reaches a final state. The launching logic is the same as bigquery_{predict|evaluate}_model_job. Args: type: BigQuery ML.ARIMA_COEFFICIENTS job type. project: Project to launch the query job. location: location to launch the query job. F...
bigquery_ml_arima_coefficients
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/ml_arima_coefficients/remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/ml_arima_coefficients/remote_runner.py
Apache-2.0
def back_quoted_if_needed(resource_name) -> str: """Enclose resource name with ` if it's not yet.""" if not resource_name or resource_name.startswith('`'): return resource_name return '`{}`'.format(resource_name)
Enclose resource name with ` if it's not yet.
back_quoted_if_needed
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
Apache-2.0
def check_if_job_exists(gcp_resources: str) -> Optional[str]: """Check if the BigQuery job already created. Args: gcp_resources: File path for storing `gcp_resources` output parameter. Returns: The job url if created, None otherwise. """ if path.exists(gcp_resources) and os.stat(gcp_resources).st_...
Check if the BigQuery job already created. Args: gcp_resources: File path for storing `gcp_resources` output parameter. Returns: The job url if created, None otherwise.
check_if_job_exists
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
Apache-2.0
def create_job( project, location, job_request_json, creds, gcp_resources ) -> str: """Create a new BigQuery job. Args: project: Project to launch the job. location: location to launch the job. For more details, see https://cloud.google.com/bigquery/docs/locations#specifying_your_location ...
Create a new BigQuery job. Args: project: Project to launch the job. location: location to launch the job. For more details, see https://cloud.google.com/bigquery/docs/locations#specifying_your_location job_request_json: A json object of Job proto. For more details, see https://clo...
create_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
Apache-2.0
def create_query_job( project, location, payload, job_configuration_query_override, creds, gcp_resources, ) -> str: """Create a new BigQuery query job. Args: project: Project to launch the query job. location: location to launch the query job. For more details, see http...
Create a new BigQuery query job. Args: project: Project to launch the query job. location: location to launch the query job. For more details, see https://cloud.google.com/bigquery/docs/locations#specifying_your_location payload: A json serialized Job proto. For more details, see h...
create_query_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
Apache-2.0
def poll_job(job_uri, creds) -> dict: """Poll the bigquery job till it reaches a final state.""" with execution_context.ExecutionContext( on_cancel=lambda: _send_cancel_request(job_uri, creds) ): job = {} while ( ('status' not in job) or ('state' not in job['status']) or (job...
Poll the bigquery job till it reaches a final state.
poll_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/bigquery/utils/bigquery_util.py
Apache-2.0
def _parse_args(args) -> Dict[str, Any]: """Parse command line arguments. Args: args: A list of arguments. Returns: A tuple containing an argparse.Namespace class instance holding parsed args, and a list containing all unknonw args. """ parser = argparse.ArgumentParser( prog='Dataflow pyth...
Parse command line arguments. Args: args: A list of arguments. Returns: A tuple containing an argparse.Namespace class instance holding parsed args, and a list containing all unknonw args.
_parse_args
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_launcher.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_launcher.py
Apache-2.0
def create_python_job( python_module_path: str, project: str, gcp_resources: str, location: str, temp_location: str, requirements_file_path: str = '', args: Optional[str] = '[]', ): """Creates a Dataflow python job. Args: python_module_path: The gcs path to the python file to run. ...
Creates a Dataflow python job. Args: python_module_path: The gcs path to the python file to run. project: Required. The project of which the resource will be launched. gcp_resources: A placeholder output for returning the gcp_resouces proto. location: Required. The region of which the resource will b...
create_python_job
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_python_job_remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_python_job_remote_runner.py
Apache-2.0
def parse_blob_path(path) -> Tuple[str, str]: """Parse a gcs path into bucket name and blob name. Args: path: the path to parse. Returns: A Tuple consisting of (bucket name in the path, blob name in the path) Raises: ValueError if the path is not a valid gcs blob path. Example: `bucket_name...
Parse a gcs path into bucket name and blob name. Args: path: the path to parse. Returns: A Tuple consisting of (bucket name in the path, blob name in the path) Raises: ValueError if the path is not a valid gcs blob path. Example: `bucket_name, blob_name = parse_blob_path('gs://foo/bar')` ...
parse_blob_path
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_python_job_remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_python_job_remote_runner.py
Apache-2.0
def download_blob(source_blob_path, destination_file_path): """Downloads a blob from the bucket. Args: source_blob_path (str): the source blob path to download from. destination_file_path (str): the local file path to download to. """ bucket_name, blob_name = parse_blob_path(source_blob_path) sto...
Downloads a blob from the bucket. Args: source_blob_path (str): the source blob path to download from. destination_file_path (str): the local file path to download to.
download_blob
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_python_job_remote_runner.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataflow/dataflow_python_job_remote_runner.py
Apache-2.0
def _get_resource(self, url: str) -> Dict[str, Any]: """GET a http request. Args: url: The resource url. Returns: Dict of the JSON payload returned in the http response. Raises: RuntimeError: Failed to get or parse the http response. """ if not self._creds.valid: self....
GET a http request. Args: url: The resource url. Returns: Dict of the JSON payload returned in the http response. Raises: RuntimeError: Failed to get or parse the http response.
_get_resource
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataproc/utils/dataproc_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataproc/utils/dataproc_util.py
Apache-2.0
def check_if_operation_exists(self) -> Union[Dict[str, Any], None]: """Check if a Dataproc Batch operation already exists. Returns: Dict of the long-running Operation resource if it exists. For more details, see: https://cloud.google.com/dataproc-serverless/docs/reference/rest/v1/projects.l...
Check if a Dataproc Batch operation already exists. Returns: Dict of the long-running Operation resource if it exists. For more details, see: https://cloud.google.com/dataproc-serverless/docs/reference/rest/v1/projects.locations.operations#Operation None if the Operation resource does not...
check_if_operation_exists
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataproc/utils/dataproc_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataproc/utils/dataproc_util.py
Apache-2.0
def wait_for_batch( self, lro: Dict[str, Any], poll_interval_seconds: int, ) -> Dict[str, Any]: """Waits for a Dataproc batch workload to reach a final state. Args: lro: Dict of the long-running Operation resource. For more details, see: https://cloud.google.com/dataproc-serve...
Waits for a Dataproc batch workload to reach a final state. Args: lro: Dict of the long-running Operation resource. For more details, see: https://cloud.google.com/dataproc-serverless/docs/reference/rest/v1/projects.locations.operations#Operation poll_interval_seconds: Seconds to wait between p...
wait_for_batch
python
kubeflow/pipelines
components/google-cloud/google_cloud_pipeline_components/container/v1/dataproc/utils/dataproc_util.py
https://github.com/kubeflow/pipelines/blob/master/components/google-cloud/google_cloud_pipeline_components/container/v1/dataproc/utils/dataproc_util.py
Apache-2.0