agvdndor commented on code in PR #23094:
URL: https://github.com/apache/beam/pull/23094#discussion_r970811841


##########
sdks/python/apache_beam/examples/ml-orchestration/kfp/components/train/src/train.py:
##########
@@ -0,0 +1,62 @@
+"""Dummy training function that loads a pretrained model from the torch hub 
and saves it."""
+
+import argparse
+from pathlib import Path
+import time
+
+import torch
+
+
+def parse_args():
+  """Parse ingestion arguments."""
+  parser = argparse.ArgumentParser()
+  parser.add_argument(
+    "--preprocessed-dataset-path", type=str,
+    help="Path to the preprocessed dataset.")
+  parser.add_argument(
+    "--trained-model-path", type=str,
+    help="Output path to the trained model.")
+  parser.add_argument(
+    "--base-artifact-path", type=str,
+    help="Base path to store pipeline artifacts.")
+  return parser.parse_args()
+
+
+def train_model(
+  preprocessed_dataset_path: str,
+  trained_model_path: str,
+  base_artifact_path: str):
+  """Dummy to load a model from the torch hub and save it.
+
+  Args:
+    preprocessed_dataset_path (str): Path to the preprocessed dataset
+    trained_model_path (str): Output path for the trained model
+    base_artifact_path (str): path to the base directory of where artifacts 
can be stored for
+      this component
+  """
+  # timestamp for the component execution
+  timestamp = time.time()
+
+  # create model or load a pretrained one
+  model = torch.hub.load('pytorch/vision:v0.10.0', 'vgg16', pretrained=True)
+
+  # TODO: train on preprocessed dataset

Review Comment:
   This is for demonstration purposes. I could change it to `to implement` to 
make it more clear?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to