From dd8ccde91bbf4602c23456f31564227b46cb8754 Mon Sep 17 00:00:00 2001 From: Nikhil Umesh Sargur Date: Mon, 4 Mar 2024 21:20:30 +0000 Subject: [PATCH] release 2.0.0-beta --- test/test_artifacts/v2/altair.test.Dockerfile | 20 ++++ ...dewhisperer-jupyterlab-ext.test.Dockerfile | 6 ++ .../v2/autogluon.test.Dockerfile | 13 +++ .../v2/aws-glue-sessions/glue_notebook.ipynb | 91 +++++++++++++++++++ .../run_glue_sessions_notebook.sh | 11 +++ test/test_artifacts/v2/boto3.test.Dockerfile | 15 +++ .../v2/glue-sessions.test.Dockerfile | 13 +++ .../v2/jupyter-ai.test.Dockerfile | 6 ++ .../v2/jupyter-dash.test.Dockerfile | 6 ++ .../v2/jupyterlab-git.test.Dockerfile | 7 ++ .../v2/jupyterlab-lsp.test.Dockerfile | 7 ++ test/test_artifacts/v2/keras.test.Dockerfile | 25 +++++ .../v2/matplotlib.test.Dockerfile | 19 ++++ .../v2/notebook.test.Dockerfile | 6 ++ test/test_artifacts/v2/numpy.test.Dockerfile | 13 +++ test/test_artifacts/v2/pandas.test.Dockerfile | 8 ++ .../v2/python-lsp-server.test.Dockerfile | 7 ++ .../v2/pytorch.examples.Dockerfile | 20 ++++ test/test_artifacts/v2/run_pandas_tests.py | 23 +++++ ...-headless-execution-driver.test.Dockerfile | 7 ++ ...studio-analytics-extension.test.Dockerfile | 11 +++ .../sagemaker-studio-analytics-extension.sh | 2 + ...sagemaker_studio_analytics_extension.ipynb | 53 +++++++++++ test/test_artifacts/v2/scipy.test.Dockerfile | 12 +++ .../scripts/run_altair_example_notebooks.sh | 18 ++++ .../v2/scripts/run_autogluon_tests.sh | 17 ++++ .../v2/scripts/run_boto3_tests.sh | 10 ++ .../v2/scripts/run_keras_tests.sh | 11 +++ .../v2/scripts/run_matplotlib_tests.sh | 7 ++ .../v2/scripts/run_pysdk_tests.sh | 20 ++++ test/test_artifacts/v2/serve.test.Dockerfile | 6 ++ .../v2/sm-python-sdk.test.Dockerfile | 13 +++ .../v2/tensorflow.examples.Dockerfile | 16 ++++ .../run_tensorflow_example_notebooks.sh | 29 ++++++ 34 files changed, 548 insertions(+) create mode 100644 test/test_artifacts/v2/altair.test.Dockerfile create mode 100644 test/test_artifacts/v2/amazon-codewhisperer-jupyterlab-ext.test.Dockerfile create mode 100644 test/test_artifacts/v2/autogluon.test.Dockerfile create mode 100644 test/test_artifacts/v2/aws-glue-sessions/glue_notebook.ipynb create mode 100644 test/test_artifacts/v2/aws-glue-sessions/run_glue_sessions_notebook.sh create mode 100644 test/test_artifacts/v2/boto3.test.Dockerfile create mode 100644 test/test_artifacts/v2/glue-sessions.test.Dockerfile create mode 100644 test/test_artifacts/v2/jupyter-ai.test.Dockerfile create mode 100644 test/test_artifacts/v2/jupyter-dash.test.Dockerfile create mode 100644 test/test_artifacts/v2/jupyterlab-git.test.Dockerfile create mode 100644 test/test_artifacts/v2/jupyterlab-lsp.test.Dockerfile create mode 100644 test/test_artifacts/v2/keras.test.Dockerfile create mode 100644 test/test_artifacts/v2/matplotlib.test.Dockerfile create mode 100644 test/test_artifacts/v2/notebook.test.Dockerfile create mode 100644 test/test_artifacts/v2/numpy.test.Dockerfile create mode 100644 test/test_artifacts/v2/pandas.test.Dockerfile create mode 100644 test/test_artifacts/v2/python-lsp-server.test.Dockerfile create mode 100644 test/test_artifacts/v2/pytorch.examples.Dockerfile create mode 100644 test/test_artifacts/v2/run_pandas_tests.py create mode 100644 test/test_artifacts/v2/sagemaker-headless-execution-driver.test.Dockerfile create mode 100644 test/test_artifacts/v2/sagemaker-studio-analytics-extension.test.Dockerfile create mode 100644 test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker-studio-analytics-extension.sh create mode 100644 test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker_studio_analytics_extension.ipynb create mode 100644 test/test_artifacts/v2/scipy.test.Dockerfile create mode 100644 test/test_artifacts/v2/scripts/run_altair_example_notebooks.sh create mode 100644 test/test_artifacts/v2/scripts/run_autogluon_tests.sh create mode 100644 test/test_artifacts/v2/scripts/run_boto3_tests.sh create mode 100644 test/test_artifacts/v2/scripts/run_keras_tests.sh create mode 100644 test/test_artifacts/v2/scripts/run_matplotlib_tests.sh create mode 100644 test/test_artifacts/v2/scripts/run_pysdk_tests.sh create mode 100644 test/test_artifacts/v2/serve.test.Dockerfile create mode 100644 test/test_artifacts/v2/sm-python-sdk.test.Dockerfile create mode 100644 test/test_artifacts/v2/tensorflow.examples.Dockerfile create mode 100644 test/test_artifacts/v2/tensorflow/run_tensorflow_example_notebooks.sh diff --git a/test/test_artifacts/v2/altair.test.Dockerfile b/test/test_artifacts/v2/altair.test.Dockerfile new file mode 100644 index 00000000..ae25a698 --- /dev/null +++ b/test/test_artifacts/v2/altair.test.Dockerfile @@ -0,0 +1,20 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import altair"] + +RUN sudo apt-get update && \ + sudo apt-get install -y git && \ + git clone --recursive https://github.com/altair-viz/altair_notebooks.git && \ + : + +WORKDIR "altair_notebooks/notebooks" +COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_altair_example_notebooks.sh ./ +RUN chmod +x run_altair_example_notebooks.sh + +# Example notebooks' dependencies +RUN micromamba install -y --freeze-installed -c conda-forge papermill vega_datasets pandas matplotlib numpy + +CMD ["./run_altair_example_notebooks.sh"] diff --git a/test/test_artifacts/v2/amazon-codewhisperer-jupyterlab-ext.test.Dockerfile b/test/test_artifacts/v2/amazon-codewhisperer-jupyterlab-ext.test.Dockerfile new file mode 100644 index 00000000..f05fd674 --- /dev/null +++ b/test/test_artifacts/v2/amazon-codewhisperer-jupyterlab-ext.test.Dockerfile @@ -0,0 +1,6 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import amazon_codewhisperer_jupyterlab_ext"] diff --git a/test/test_artifacts/v2/autogluon.test.Dockerfile b/test/test_artifacts/v2/autogluon.test.Dockerfile new file mode 100644 index 00000000..6b448697 --- /dev/null +++ b/test/test_artifacts/v2/autogluon.test.Dockerfile @@ -0,0 +1,13 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE as base + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +RUN micromamba install --freeze-installed -y -c conda-forge pytest + +RUN git clone --recursive https://github.com/autogluon/autogluon.git + +WORKDIR "autogluon" +COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_autogluon_tests.sh . +RUN chmod +x run_autogluon_tests.sh +CMD ["./run_autogluon_tests.sh"] diff --git a/test/test_artifacts/v2/aws-glue-sessions/glue_notebook.ipynb b/test/test_artifacts/v2/aws-glue-sessions/glue_notebook.ipynb new file mode 100644 index 00000000..b491f310 --- /dev/null +++ b/test/test_artifacts/v2/aws-glue-sessions/glue_notebook.ipynb @@ -0,0 +1,91 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "1a710e7c-7ebf-477a-88b5-3d85cb08cf19", + "metadata": {}, + "outputs": [], + "source": [ + "%status" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0ce599e8-6dcc-42c4-b10d-8e4e898eb436", + "metadata": {}, + "outputs": [], + "source": [ + "%stop_session" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "013565d2-26dc-4710-83ca-1d00711be6c9", + "metadata": {}, + "outputs": [], + "source": [ + "%glue_ray" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e81bb7c2-bec2-4c4b-8d4d-59bf5e6a9daf", + "metadata": {}, + "outputs": [], + "source": [ + "%etl" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7a0b5de5-bf14-40f9-a944-f98e5a96e0f4", + "metadata": {}, + "outputs": [], + "source": [ + "%streaming" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cf24f505-6f26-447e-acc3-4af4556bb386", + "metadata": {}, + "outputs": [], + "source": [ + "%help" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "33149d30-420e-4ebf-b32c-ca635db7cb10", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Glue PySpark and Ray", + "language": "python", + "name": "glue_pyspark" + }, + "language_info": { + "codemirror_mode": { + "name": "python", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "Python_Glue_Session", + "pygments_lexer": "python3" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/test/test_artifacts/v2/aws-glue-sessions/run_glue_sessions_notebook.sh b/test/test_artifacts/v2/aws-glue-sessions/run_glue_sessions_notebook.sh new file mode 100644 index 00000000..fbf5faf2 --- /dev/null +++ b/test/test_artifacts/v2/aws-glue-sessions/run_glue_sessions_notebook.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Create an empty notebook file for papermill's output +touch nb_output.ipynb + +kernels=('glue_pyspark' 'glue_spark') +nb='script' +for kernel in ${kernels[@]}; do + papermill 'glue_notebook.ipynb' 'nb_output.ipynb' -k $kernel +done + diff --git a/test/test_artifacts/v2/boto3.test.Dockerfile b/test/test_artifacts/v2/boto3.test.Dockerfile new file mode 100644 index 00000000..5223f561 --- /dev/null +++ b/test/test_artifacts/v2/boto3.test.Dockerfile @@ -0,0 +1,15 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 +RUN sudo apt-get update && sudo apt-get install -y git && \ + git clone --recursive https://github.com/boto/boto3.git && \ + : + +# For Running boto3 tests, we need pytest +RUN micromamba install -y --freeze-installed -c conda-forge pytest + +WORKDIR "boto3" +COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_boto3_tests.sh . +RUN chmod +x run_boto3_tests.sh +CMD ["./run_boto3_tests.sh"] diff --git a/test/test_artifacts/v2/glue-sessions.test.Dockerfile b/test/test_artifacts/v2/glue-sessions.test.Dockerfile new file mode 100644 index 00000000..9f87a400 --- /dev/null +++ b/test/test_artifacts/v2/glue-sessions.test.Dockerfile @@ -0,0 +1,13 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +COPY --chown=$MAMBA_USER:$MAMBA_USER aws-glue-sessions/run_glue_sessions_notebook.sh . +RUN chmod +x run_glue_sessions_notebook.sh +COPY --chown=$MAMBA_USER:$MAMBA_USER aws-glue-sessions/glue_notebook.ipynb . +RUN chmod +x glue_notebook.ipynb + +RUN micromamba install -y --freeze-installed -c conda-forge papermill + +CMD ["./run_glue_sessions_notebook.sh"] diff --git a/test/test_artifacts/v2/jupyter-ai.test.Dockerfile b/test/test_artifacts/v2/jupyter-ai.test.Dockerfile new file mode 100644 index 00000000..e231adf7 --- /dev/null +++ b/test/test_artifacts/v2/jupyter-ai.test.Dockerfile @@ -0,0 +1,6 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import jupyter_ai"] diff --git a/test/test_artifacts/v2/jupyter-dash.test.Dockerfile b/test/test_artifacts/v2/jupyter-dash.test.Dockerfile new file mode 100644 index 00000000..b4b92126 --- /dev/null +++ b/test/test_artifacts/v2/jupyter-dash.test.Dockerfile @@ -0,0 +1,6 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import plotly.express as px; import sys; fig = px.bar(x=['a', 'b', 'c'], y=[1, 3, 2]); fig.write_html('first_figure.html', auto_open=False)"] diff --git a/test/test_artifacts/v2/jupyterlab-git.test.Dockerfile b/test/test_artifacts/v2/jupyterlab-git.test.Dockerfile new file mode 100644 index 00000000..11732655 --- /dev/null +++ b/test/test_artifacts/v2/jupyterlab-git.test.Dockerfile @@ -0,0 +1,7 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import jupyterlab_git"] + diff --git a/test/test_artifacts/v2/jupyterlab-lsp.test.Dockerfile b/test/test_artifacts/v2/jupyterlab-lsp.test.Dockerfile new file mode 100644 index 00000000..0aed1baf --- /dev/null +++ b/test/test_artifacts/v2/jupyterlab-lsp.test.Dockerfile @@ -0,0 +1,7 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import jupyter_lsp"] +CMD ["python", "-c", "import jupyterlab_lsp"] diff --git a/test/test_artifacts/v2/keras.test.Dockerfile b/test/test_artifacts/v2/keras.test.Dockerfile new file mode 100644 index 00000000..0d03504f --- /dev/null +++ b/test/test_artifacts/v2/keras.test.Dockerfile @@ -0,0 +1,25 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +RUN sudo apt-get update && sudo apt-get install -y git graphviz && \ + git clone --recursive https://github.com/keras-team/keras-io.git && \ + : + +# Some of the keras guides requires pydot and graphviz to be installed +RUN micromamba install -y --freeze-installed conda-forge::pydot nvidia::cuda-nvcc +ENV XLA_FLAGS=--xla_gpu_cuda_data_dir=/opt/conda + +WORKDIR "keras-io/guides" + +# Checkout a specific commit known to be compatible with the runtime's current version of TensorFlow. +# keras-io made backwards incompatible changes that broke these tests. Pinning at this commit for now +# at least until the runtime's TensorFlow dependency is upgraded to the next minor version +RUN git checkout 861b59747b43ce326bb0a12384a07d6632249901 + +COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_keras_tests.sh . +RUN chmod +x run_keras_tests.sh +# Run tests in run_keras_tests.sh +CMD ["./run_keras_tests.sh"] + diff --git a/test/test_artifacts/v2/matplotlib.test.Dockerfile b/test/test_artifacts/v2/matplotlib.test.Dockerfile new file mode 100644 index 00000000..95b63731 --- /dev/null +++ b/test/test_artifacts/v2/matplotlib.test.Dockerfile @@ -0,0 +1,19 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +RUN sudo apt-get update && sudo apt-get install -y git && \ + git clone --recursive https://github.com/matplotlib/matplotlib.git && \ + : + +# TODO: Come up with a different way to test matplotlib installation. +# Currently we will be running all the python files in galleries/tutorials +# But this directory structure might change in the future. In the past, "galleries/tutorials" +# didn't exist. Previously the repository just had a "tutorials" folder. +WORKDIR "matplotlib/galleries/tutorials" +COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_matplotlib_tests.sh . +RUN chmod +x run_matplotlib_tests.sh +# Run tests in run_matplotlib_tests.sh +CMD ["./run_matplotlib_tests.sh"] + diff --git a/test/test_artifacts/v2/notebook.test.Dockerfile b/test/test_artifacts/v2/notebook.test.Dockerfile new file mode 100644 index 00000000..16ca7e39 --- /dev/null +++ b/test/test_artifacts/v2/notebook.test.Dockerfile @@ -0,0 +1,6 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import notebook"] diff --git a/test/test_artifacts/v2/numpy.test.Dockerfile b/test/test_artifacts/v2/numpy.test.Dockerfile new file mode 100644 index 00000000..6e622f40 --- /dev/null +++ b/test/test_artifacts/v2/numpy.test.Dockerfile @@ -0,0 +1,13 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +# Inorder to test numpy, we need pytest and hypothesis to be installed. +RUN micromamba install -y --freeze-installed -c conda-forge pytest hypothesis meson +# Some unit tests in numpy requires gcc to be installed. +RUN sudo apt-get update && sudo apt-get install -y gcc +# Check https://numpy.org/doc/stable/reference/testing.html +# numpy.test() returns True if tests succeed else False. +# We need to flip the result so that we exit with status code as 0 if all the tests succeeded. +CMD ["python", "-c", "import numpy,sys; tests_succeeded = numpy.test(); sys.exit(not tests_succeeded)"] diff --git a/test/test_artifacts/v2/pandas.test.Dockerfile b/test/test_artifacts/v2/pandas.test.Dockerfile new file mode 100644 index 00000000..68b0bfa0 --- /dev/null +++ b/test/test_artifacts/v2/pandas.test.Dockerfile @@ -0,0 +1,8 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 +RUN micromamba install -y --freeze-installed -c conda-forge pytest hypothesis pytest-asyncio lxml + +COPY --chown=$MAMBA_USER:$MAMBA_USER run_pandas_tests.py . +CMD ["python", "run_pandas_tests.py"] diff --git a/test/test_artifacts/v2/python-lsp-server.test.Dockerfile b/test/test_artifacts/v2/python-lsp-server.test.Dockerfile new file mode 100644 index 00000000..24b38e7f --- /dev/null +++ b/test/test_artifacts/v2/python-lsp-server.test.Dockerfile @@ -0,0 +1,7 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +# "Confirm that installation succeeded" by running this - https://github.com/python-lsp/python-lsp-server#installation +CMD ["pylsp", "--help"] diff --git a/test/test_artifacts/v2/pytorch.examples.Dockerfile b/test/test_artifacts/v2/pytorch.examples.Dockerfile new file mode 100644 index 00000000..ca4e6615 --- /dev/null +++ b/test/test_artifacts/v2/pytorch.examples.Dockerfile @@ -0,0 +1,20 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 +RUN sudo apt-get update && \ + sudo apt-get install -y git && \ + git clone --recursive https://github.com/pytorch/examples && \ + : + +WORKDIR "examples" + +# There is a line in run_python_examples.sh which looks like: BASE_DIR=`pwd`"/"`dirname $0` +# When we run the shell script through /usr/local/bin/_entrypoint.sh, that line above doesn't work correctly. In our +# case, we properly set `pwd` to the directory that contains all the examples, so we just modify the script to change +# the previous line to look like: BASE_DIR=`pwd` +RUN sed -i 's/^BASE_DIR=.*pwd.*dirname.*/BASE_DIR=`pwd`/' run_python_examples.sh +RUN ./run_python_examples.sh install_deps + +# We skip `imagenet` because it requires a lot of resources and so aren't a good fit for us. +CMD ["./run_python_examples.sh", "dcgan,fast_neural_style,distributed,mnist,mnist_forward_forward,mnist_hogwild,mnist_rnn,regression,reinforcement_learning,siamese_network,super_resolution,time_sequence_prediction,vae,word_language_model,fx"] diff --git a/test/test_artifacts/v2/run_pandas_tests.py b/test/test_artifacts/v2/run_pandas_tests.py new file mode 100644 index 00000000..00127f2d --- /dev/null +++ b/test/test_artifacts/v2/run_pandas_tests.py @@ -0,0 +1,23 @@ +import pandas, sys, os, site + +# We change the working directory here because there is at least one test (`test_html_template_extends_options`) which +# expects the directory to be 'pandas'. Ideally, we would have changed directories through a `WORKDIR` in Dockerfile +# but unfortunately it doesn't accept dynamic arguments. +site_packages_dir = site.getsitepackages()[0] +os.chdir(site_packages_dir) + +# pandas.test() by default runs with `-m "not slow and not network and not db"`. However, we found a few tests in the +# test_network.py file that should have been marked as "network" but weren't, so we skip those here. We skip S3 specific +# tests for the same reason. +# We skip `test_plain_axes` too: the Pandas dev environment expects matplotlib to be ">=3.6.1, <3.7.0" but the runtime +# expectation is just ">=3.6.1". Our image contains v3.7.1, so it meets the latter requirement but not the former. This +# particular test, however, only works with the former requirement. (We verified that the test succeeds if we manually +# drop the version to v3.6.x) So, we skip it. +# Also skipping specific TestFrameFlexArithmetic test; failing due to known issue https://github.com/pandas-dev/pandas/issues/54546 +tests_succeeded = pandas.test([ + '-m', '(not slow and not network and not db)', + '-k', '(not test_network and not s3 and not test_plain_axes)', + '--no-strict-data-files', + '--ignore', 'pandas/tests/frame/test_arithmetic.py::TestFrameFlexArithmetic::test_floordiv_axis0_numexpr_path']) + +sys.exit(not tests_succeeded) diff --git a/test/test_artifacts/v2/sagemaker-headless-execution-driver.test.Dockerfile b/test/test_artifacts/v2/sagemaker-headless-execution-driver.test.Dockerfile new file mode 100644 index 00000000..675960df --- /dev/null +++ b/test/test_artifacts/v2/sagemaker-headless-execution-driver.test.Dockerfile @@ -0,0 +1,7 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +# Execute the unit tests for sagemaker-headless-execution-driver +CMD ["python", "-c", "import sagemaker_headless_execution_driver.headless_execution as execution_driver"] diff --git a/test/test_artifacts/v2/sagemaker-studio-analytics-extension.test.Dockerfile b/test/test_artifacts/v2/sagemaker-studio-analytics-extension.test.Dockerfile new file mode 100644 index 00000000..ba835032 --- /dev/null +++ b/test/test_artifacts/v2/sagemaker-studio-analytics-extension.test.Dockerfile @@ -0,0 +1,11 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +COPY --chown=$MAMBA_USER:$MAMBA_USER ./sagemaker-studio-analytics-extension . +RUN chmod +x ./sagemaker-studio-analytics-extension.sh + +RUN micromamba install -y --freeze-installed -c conda-forge papermill + +CMD ["./sagemaker-studio-analytics-extension.sh"] diff --git a/test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker-studio-analytics-extension.sh b/test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker-studio-analytics-extension.sh new file mode 100644 index 00000000..c864676b --- /dev/null +++ b/test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker-studio-analytics-extension.sh @@ -0,0 +1,2 @@ +#!/bin/bash +papermill 'sagemaker_studio_analytics_extension.ipynb' 'nb_output.ipynb' diff --git a/test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker_studio_analytics_extension.ipynb b/test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker_studio_analytics_extension.ipynb new file mode 100644 index 00000000..fb92e3a8 --- /dev/null +++ b/test/test_artifacts/v2/sagemaker-studio-analytics-extension/sagemaker_studio_analytics_extension.ipynb @@ -0,0 +1,53 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "3d5383b9-e06d-42de-b7b7-3ad9603c9585", + "metadata": {}, + "outputs": [], + "source": [ + "%load_ext sagemaker_studio_analytics_extension.magics" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "feb385d0-c80e-4d65-afe7-8e6beb07e836", + "metadata": {}, + "outputs": [], + "source": [ + "%sm_analytics?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a3faecce-f008-4ac9-94e7-d6bfc6f88bb1", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.12" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/test/test_artifacts/v2/scipy.test.Dockerfile b/test/test_artifacts/v2/scipy.test.Dockerfile new file mode 100644 index 00000000..cf88992a --- /dev/null +++ b/test/test_artifacts/v2/scipy.test.Dockerfile @@ -0,0 +1,12 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +# Inorder to test scipy, we need pytest and hypothesis to be installed. +RUN micromamba install -y --freeze-installed -c conda-forge pytest hypothesis scipy-tests pooch +# Check https://github.com/numpy/numpy/blob/main/doc/TESTS.rst +# Note: Testing guidelines are same for numpy and scipy. +# scipy.test() returns True if tests succeed else False. +# We need to flip the result so that we exit with status code as 0 if all the tests succeeded. +CMD ["python", "-c", "import scipy,sys; tests_succeeded = scipy.test(); sys.exit(not tests_succeeded)"] diff --git a/test/test_artifacts/v2/scripts/run_altair_example_notebooks.sh b/test/test_artifacts/v2/scripts/run_altair_example_notebooks.sh new file mode 100644 index 00000000..47762d0f --- /dev/null +++ b/test/test_artifacts/v2/scripts/run_altair_example_notebooks.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Create an empty notebook file for papermill's output +touch nb_output.ipynb + +# List of example notebooks under the altair_notebooks' notebooks/ subdirectory, excluding examples +example_notebooks=('02-Tutorial.ipynb' + '03-ScatterCharts.ipynb' + '04-BarCharts.ipynb' + '05-LineCharts.ipynb' + '07-LayeredCharts.ipynb' + '08-CarsDataset.ipynb' +) + +for nb in ${example_notebooks[@]}; do + papermill $nb 'nb_output.ipynb' +done + diff --git a/test/test_artifacts/v2/scripts/run_autogluon_tests.sh b/test/test_artifacts/v2/scripts/run_autogluon_tests.sh new file mode 100644 index 00000000..036d1432 --- /dev/null +++ b/test/test_artifacts/v2/scripts/run_autogluon_tests.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +AUTOGLUON_VERSION=$(micromamba list | grep autogluon | tr -s ' ' | cut -d ' ' -f 3) +git checkout tags/v$AUTOGLUON_VERSION + +# Run autogluon quick start as end-to-end check +jupyter nbconvert --execute --to python docs/tutorials/tabular/tabular-quick-start.ipynb +jupyter nbconvert --execute --to python docs/tutorials/timeseries/forecasting-quick-start.ipynb + +# Detect gpu and run multimodal quick start if presented +python -c "import torch; exit(0) if torch.cuda.is_available() else exit(1)" +ret=$? + +if [ $ret -eq 0 ] +then + jupyter nbconvert --execute --to python docs/tutorials/multimodal/multimodal_prediction/multimodal-quick-start.ipynb +fi diff --git a/test/test_artifacts/v2/scripts/run_boto3_tests.sh b/test/test_artifacts/v2/scripts/run_boto3_tests.sh new file mode 100644 index 00000000..ab0c7803 --- /dev/null +++ b/test/test_artifacts/v2/scripts/run_boto3_tests.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# We need to checkout the version of boto3 that is installed in the mamba environment. + +boto3_version=$(micromamba list | grep boto3 | tr -s ' ' | cut -d ' ' -f 3) +# Checkout the corresponding boto3 version +git checkout tags/$boto3_version + +# Run the unit and functional tests +pytest tests/unit tests/functional || exit $? diff --git a/test/test_artifacts/v2/scripts/run_keras_tests.sh b/test/test_artifacts/v2/scripts/run_keras_tests.sh new file mode 100644 index 00000000..aa8f7fdd --- /dev/null +++ b/test/test_artifacts/v2/scripts/run_keras_tests.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Ref: https://keras.io/guides/, https://github.com/keras-team/keras-io/tree/master + +for file in *.py; do + if [ "$file" != "transfer_learning.py" ]; then + # skipping transfer_learning.py because it has 20 epochs and it takes a very long time to execute + # https://github.com/keras-team/keras-io/blob/master/guides/transfer_learning.py#L562 + python "$file" || exit $? + fi +done diff --git a/test/test_artifacts/v2/scripts/run_matplotlib_tests.sh b/test/test_artifacts/v2/scripts/run_matplotlib_tests.sh new file mode 100644 index 00000000..13aa3fb3 --- /dev/null +++ b/test/test_artifacts/v2/scripts/run_matplotlib_tests.sh @@ -0,0 +1,7 @@ +#!/bin/bash +# Run all the tutorials +for file in *.py; do + python "$file" || exit $? +done + + diff --git a/test/test_artifacts/v2/scripts/run_pysdk_tests.sh b/test/test_artifacts/v2/scripts/run_pysdk_tests.sh new file mode 100644 index 00000000..2f49f122 --- /dev/null +++ b/test/test_artifacts/v2/scripts/run_pysdk_tests.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# We need to checkout the version of sagemaker-python-sdk that is installed in the mamba environment. + +pysdk_version=$(micromamba list | grep sagemaker-python-sdk | tr -s ' ' | cut -d ' ' -f 3) +# Checkout the corresponding sagemaker-python-sdk version +git checkout tags/v$pysdk_version + +# Install test dependencies of sagemaker-python-sdk +# Using pip as some of the packages are not available on conda-forge +pip install -r requirements/extras/test_requirements.txt + +# Run the unit tests, ignoring tests which require AWS Configuration +# TODO: Re-evaluate the ignored tests since we are setting the AWS_DEFAULT_REGION as part of the Dockerfile. +pytest tests/unit --ignore=tests/unit/sagemaker/feature_store/ --ignore=tests/unit/sagemaker/jumpstart/ --ignore=tests/unit/sagemaker/workflow/ \ + --ignore=tests/unit/sagemaker/async_inference --ignore=tests/unit/test_model_card.py --ignore=tests/unit/test_model_card.py --ignore=tests/unit/test_processing.py \ + --ignore=tests/unit/test_tensorboard.py --ignore=tests/unit/sagemaker/async_inference --ignore=tests/unit/sagemaker/experiments --ignore tests/unit/sagemaker/local \ + --ignore tests/unit/sagemaker/monitor/test_data_capture_config.py --ignore tests/unit/sagemaker/experiments --ignore tests/unit/sagemaker/remote_function \ + --ignore tests/unit/sagemaker/model/test_deploy.py --deselect tests/unit/test_estimator.py::test_insert_invalid_source_code_args \ + --deselect tests/unit/sagemaker/tensorflow/test_estimator.py::test_insert_invalid_source_code_args || exit $? diff --git a/test/test_artifacts/v2/serve.test.Dockerfile b/test/test_artifacts/v2/serve.test.Dockerfile new file mode 100644 index 00000000..671fd73a --- /dev/null +++ b/test/test_artifacts/v2/serve.test.Dockerfile @@ -0,0 +1,6 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 + +CMD ["python", "-c", "import fastapi, uvicorn, langchain"] \ No newline at end of file diff --git a/test/test_artifacts/v2/sm-python-sdk.test.Dockerfile b/test/test_artifacts/v2/sm-python-sdk.test.Dockerfile new file mode 100644 index 00000000..4a9c8d7d --- /dev/null +++ b/test/test_artifacts/v2/sm-python-sdk.test.Dockerfile @@ -0,0 +1,13 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 +RUN sudo apt-get update && sudo apt-get install -y git && \ + git clone --recursive https://github.com/aws/sagemaker-python-sdk.git && \ + : +# Sagemaker Python SDK's unit tests requires AWS_DEFAULT_REGION to be set. So, using an arbitrary value of us-east-1 +ENV AWS_DEFAULT_REGION=us-east-1 +WORKDIR "sagemaker-python-sdk" +COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_pysdk_tests.sh . +RUN chmod +x run_pysdk_tests.sh +CMD ["./run_pysdk_tests.sh"] diff --git a/test/test_artifacts/v2/tensorflow.examples.Dockerfile b/test/test_artifacts/v2/tensorflow.examples.Dockerfile new file mode 100644 index 00000000..f88bc9f2 --- /dev/null +++ b/test/test_artifacts/v2/tensorflow.examples.Dockerfile @@ -0,0 +1,16 @@ +ARG COSMOS_IMAGE +FROM $COSMOS_IMAGE + +ARG MAMBA_DOCKERFILE_ACTIVATE=1 +RUN sudo apt-get update && \ + sudo apt-get install -y git && \ + git clone --recursive https://github.com/tensorflow/docs.git && \ + : + +WORKDIR "docs/site/en/guide" +COPY --chown=$MAMBA_USER:$MAMBA_USER tensorflow ./ +RUN chmod +x run_tensorflow_example_notebooks.sh + +RUN micromamba install -y --freeze-installed -c conda-forge papermill + +CMD ["./run_tensorflow_example_notebooks.sh"] diff --git a/test/test_artifacts/v2/tensorflow/run_tensorflow_example_notebooks.sh b/test/test_artifacts/v2/tensorflow/run_tensorflow_example_notebooks.sh new file mode 100644 index 00000000..22887459 --- /dev/null +++ b/test/test_artifacts/v2/tensorflow/run_tensorflow_example_notebooks.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Create an empty notebook file for papermill's output +touch nb_output.ipynb + +# List of all referenced notebook files in Basics, Core, and In Depth sections of Tensorflow docs, excluding experimentals. +# https://www.tensorflow.org/guide +example_notebooks=('basics.ipynb' + 'tensor.ipynb' + 'variable.ipynb' + 'autodiff.ipynb' + 'intro_to_graphs.ipynb' + 'intro_to_modules.ipynb' + 'basic_training_loops.ipynb' + 'core/quickstart_core.ipynb' + 'core/logistic_regression_core.ipynb' + 'core/mlp_core.ipynb' + 'core/matrix_core.ipynb' + 'core/optimizers_core.ipynb' + 'tensor_slicing.ipynb' + 'advanced_autodiff.ipynb' + 'ragged_tensor.ipynb' + 'sparse_tensor.ipynb' + 'random_numbers.ipynb' +) + +for nb in ${example_notebooks[@]}; do + papermill $nb 'nb_output.ipynb' +done