Dear committee, There is only Python sample code in "Build your Model" section. For other sections, there are codes for R. Could you please provide sample code in Python for run_model.R and "Create a Dockerfile"? Thank you very much Best regards, Robin

Created by Chih-Han Huang Chih-Han
Thank you very much!
Dear @Chih-Han , Great question. Here is a sample Dockerfile for a model written in Python: ``` # Use Python 3.8 with minimal packages installed. # This is a size-saving alternative to using `python:3.8` as the base image. FROM python:3.8-slim-buster # Install additional libraries if needed RUN pip install pandas scikit-learn ... # Copy files and scripts needed to run the model. COPY run_model.py /usr/local/bin/. # Run the Python script upon starting the Docker container. ENTRYPOINT ["python", "/usr/local/bin/run_model.py"] ``` where `run_model.py` could look something like this: ```python import os import argparse import pandas as pd def get_args(): parser = argparse.ArgumentParser() parser.add_argument("-i", "--input_dir", type=str, default="/input") parser.add_argument("-o", "--output_dir", type=str, default="/output") return parser.parse_args() def model(parent): metadata = pd.read_csv( os.path.join(parent, "metadata", "metadata.csv") ) results = "..." return results def main(): args = get_args() results = model(args.input_dir) with open(os.path.join(args.output_dir, "predictions.csv"), "w") as out: out.write(results) if __name__ == "__main__": main() ```

Python version of Submission Tutorial (Docker) page is loading…