Skip to content

Bhavyssh/add UT #594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions test/test_artifacts/v2/fastapi.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

RUN sudo apt-get update && \
sudo apt-get install -y git && \
git clone --recursive https://github.com/fastapi/fastapi

WORKDIR "fastapi"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_fastapi_tests.sh .

RUN chmod +x run_fastapi_tests.sh

CMD ["./run_fastapi_tests.sh"]

20 changes: 20 additions & 0 deletions test/test_artifacts/v2/ipywidgets.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

ENV OPENBLAS_NUM_THREADS=1

RUN sudo apt-get update && \
sudo apt-get install -y git

RUN git clone https://github.com/jupyter-widgets/ipywidgets.git

WORKDIR "ipywidgets"

RUN pip install jupyter nbconvert

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_ipywidgets_tests.sh ./
RUN chmod +x run_ipywidgets_tests.sh

CMD ["./run_ipywidgets_tests.sh"]
14 changes: 14 additions & 0 deletions test/test_artifacts/v2/jinja2.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

ENV OPENBLAS_NUM_THREADS=1

RUN micromamba install -y -c conda-forge jinja2

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_jinja2_tests.sh ./

RUN chmod +x run_jinja2_tests.sh

CMD ["./run_jinja2_tests.sh"]
13 changes: 12 additions & 1 deletion test/test_artifacts/v2/jupyter-collaboration.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

CMD ["python", "-c", "import jupyter_collaboration; import jupyter_server_fileid; from jupyter_ydoc import YBlob; yblob = YBlob(); assert yblob.get() == b''; yblob.set(b'012'); assert yblob.get() == b'012'"]
RUN sudo apt-get update && \
sudo apt-get install -y git

RUN git clone --recursive https://github.com/jupyterlab/jupyter-collaboration.git

WORKDIR "jupyter-collaboration"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_jupyter_collaboration_tests.sh .

RUN chmod +x run_jupyter_collaboration_tests.sh

CMD ["./run_jupyter_collaboration_tests.sh"]
17 changes: 17 additions & 0 deletions test/test_artifacts/v2/jupyter-scheduler.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

RUN sudo apt-get update && \
sudo apt-get install -y git && \
git clone --recursive https://github.com/jupyter-server/jupyter-scheduler

WORKDIR "jupyter-scheduler"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_jupyter_scheduler_tests.sh .

RUN chmod +x run_jupyter_scheduler_tests.sh

CMD ["./run_jupyter_scheduler_tests.sh"]

16 changes: 16 additions & 0 deletions test/test_artifacts/v2/jupyter-server-proxy.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

RUN sudo apt-get update && \
sudo apt-get install -y git && \
git clone --recursive https://github.com/jupyterhub/jupyter-server-proxy.git

WORKDIR "jupyter-server-proxy"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_jupyter_server_proxy_tests.sh .

RUN chmod +x run_jupyter_server_proxy_tests.sh

CMD ["./run_jupyter_server_proxy_tests.sh"]
14 changes: 13 additions & 1 deletion test/test_artifacts/v2/jupyterlab-git.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,16 @@ FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

CMD ["python", "-c", "import jupyterlab_git"]
RUN sudo apt-get update && \
sudo apt-get install -y git

RUN git clone --recursive https://github.com/jupyterlab/jupyterlab-git

WORKDIR "jupyterlab-git"

RUN micromamba install --freeze-installed -y -c conda-forge pytest

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_jupyterlab_git_tests.sh .
RUN chmod +x run_jupyterlab_git_tests.sh

CMD ["./run_jupyterlab_git_tests.sh"]
7 changes: 5 additions & 2 deletions test/test_artifacts/v2/jupyterlab-lsp.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

CMD ["python", "-c", "import jupyter_lsp"]
CMD ["python", "-c", "import jupyterlab_lsp"]
COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_jupyterlab_lsp_tests.sh ./
RUN chmod +x run_jupyterlab_lsp_tests.sh

CMD ["./run_jupyterlab_lsp_tests.sh"]

13 changes: 0 additions & 13 deletions test/test_artifacts/v2/langchain-aws.test.Dockerfile

This file was deleted.

28 changes: 28 additions & 0 deletions test/test_artifacts/v2/langchain.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

ENV OPENBLAS_NUM_THREADS=1

RUN micromamba install -y -c conda-forge pytest

# Create the test script
RUN echo '#!/bin/bash' > /home/sagemaker-user/run_langchain_tests.sh && \
echo 'set -e' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo 'echo "Langchain version: $(python -c "import langchain; print(langchain.__version__)")"' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo 'langchain_path=$(python -c "import langchain; import os; print(os.path.dirname(langchain.__file__))")' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo 'test_path="${langchain_path}/tests/unit_tests"' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo 'if [ -d "$test_path" ]; then' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo ' pytest "$test_path" -v' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo 'else' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo ' echo "Unit tests directory not found at $test_path"' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo ' echo "Available files in langchain directory:"' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo ' find "$langchain_path" -name "*.py"' >> /home/sagemaker-user/run_langchain_tests.sh && \
echo 'fi' >> /home/sagemaker-user/run_langchain_tests.sh

RUN chmod +x /home/sagemaker-user/run_langchain_tests.sh

WORKDIR /home/sagemaker-user

CMD ["./run_langchain_tests.sh"]
13 changes: 12 additions & 1 deletion test/test_artifacts/v2/notebook.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@ FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

CMD ["python", "-c", "import notebook"]
RUN sudo apt-get update && \
sudo apt-get install -y git && \
git clone --recursive https://github.com/jupyter/notebook

WORKDIR "notebook"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_notebook_tests.sh .

RUN chmod +x run_notebook_tests.sh

CMD ["./run_notebook_tests.sh"]

17 changes: 17 additions & 0 deletions test/test_artifacts/v2/pyhive.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

RUN sudo apt-get update && \
sudo apt-get install -y git && \
git clone --recursive https://github.com/dropbox/PyHive.git

WORKDIR "PyHive"

RUN micromamba install --freeze-installed -y -c conda-forge pytest

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_pyhive_tests.sh .
RUN chmod +x run_pyhive_tests.sh

CMD ["./run_pyhive_tests.sh"]
11 changes: 9 additions & 2 deletions test/test_artifacts/v2/python-lsp-server.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,12 @@ FROM $SAGEMAKER_DISTRIBUTION_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"]
RUN sudo apt-get update && \
sudo apt-get install -y git && \
git clone --recursive https://github.com/python-lsp/python-lsp-server

WORKDIR "python-lsp"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_python_lsp_server_tests.sh .

RUN chmod +x run_python_lsp_server_tests.sh
4 changes: 3 additions & 1 deletion test/test_artifacts/v2/run_pandas_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
"-m",
"(not slow and not network and not db and not clipboard)",
"-k",
"(not test_network and not s3 and not test_plain_axes)",
"(not test_network and not s3 and not test_plain_axes and not test_xsqlite_execute_closed_connection and not test_sql)",
"-W",
"ignore::PendingDeprecationWarning",
"--no-strict-data-files",
"--ignore",
"pandas/tests/frame/test_arithmetic.py::TestFrameFlexArithmetic::test_floordiv_axis0_numexpr_path",
Expand Down
1 change: 1 addition & 0 deletions test/test_artifacts/v2/s3fs.test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARG MAMBA_DOCKERFILE_ACTIVATE=1
RUN git clone --recursive https://github.com/fsspec/s3fs.git

WORKDIR "s3fs"

COPY --chown=$MAMBA_USER:$MAMBA_USER scripts/run_s3fs_tests.sh .
RUN chmod +x run_s3fs_tests.sh
CMD ["./run_s3fs_tests.sh"]
23 changes: 23 additions & 0 deletions test/test_artifacts/v2/scikit-learn.test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
ARG SAGEMAKER_DISTRIBUTION_IMAGE
FROM $SAGEMAKER_DISTRIBUTION_IMAGE

ARG MAMBA_DOCKERFILE_ACTIVATE=1

ENV OPENBLAS_NUM_THREADS=1

RUN micromamba install -y --name base -c conda-forge pytest pytest-cov

RUN echo '#!/bin/bash' > /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo 'import_path=$(python -c "import sklearn; print(sklearn.__file__)")' >> /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo 'sklearn_path=$(dirname "$import_path")' >> /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo 'test_files=("test_base.py" "test_init.py")' >> /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo 'for test_file in "${test_files[@]}"; do' >> /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo ' echo "Running tests in $test_file"' >> /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo ' pytest -v "$sklearn_path/tests/$test_file"' >> /home/sagemaker-user/run_scikit_learn_tests.sh && \
echo 'done' >> /home/sagemaker-user/run_scikit_learn_tests.sh

RUN chmod +x /home/sagemaker-user/run_scikit_learn_tests.sh

WORKDIR /home/sagemaker-user

CMD ["./run_scikit_learn_tests.sh"]
9 changes: 9 additions & 0 deletions test/test_artifacts/v2/scripts/run_fastapi_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

fastapi_version=$(micromamba list | grep fastapi | tr -s ' ' | cut -d ' ' -f 3)

git checkout tags/v$fastapi_version

pip install -r requirements-tests.txt

pytest tests/ -v -k "not test_tutorial"
4 changes: 4 additions & 0 deletions test/test_artifacts/v2/scripts/run_ipywidgets_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

jupyter nbconvert --execute --to python tests/test_borders.ipynb
jupyter nbconvert --execute --to python tests/test_sanitizer.ipynb
74 changes: 74 additions & 0 deletions test/test_artifacts/v2/scripts/run_jinja2_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

set -e

# Test 1: Basic template
python -c "
from jinja2 import Template
template = Template('Hello {{ name }}!')
result = template.render(name='John')
assert result == 'Hello John!', f'Expected \"Hello John!\", got \"{result}\"'
"

# Test 2: Conditional statements
python -c "
from jinja2 import Template
template = Template('{% if user %}Hello, {{ user }}!{% else %}Hello, stranger!{% endif %}')
result1 = template.render(user='Alice')
result2 = template.render(user=None)
assert result1 == 'Hello, Alice!', f'Expected \"Hello, Alice!\", got \"{result1}\"'
assert result2 == 'Hello, stranger!', f'Expected \"Hello, stranger!\", got \"{result2}\"'
"

# Test 3: Loops
python -c "
from jinja2 import Template
template = Template('{% for item in items %}{{ item }} {% endfor %}')
result = template.render(items=['apple', 'banana', 'cherry'])
assert result == 'apple banana cherry ', f'Expected \"apple banana cherry \", got \"{result}\"'
"

# Test 4: Filters
python -c "
from jinja2 import Template
template = Template('{{ name|upper }}')
result = template.render(name='john')
assert result == 'JOHN', f'Expected \"JOHN\", got \"{result}\"'
"

# Test 5: File system loader
echo "<h1>Hello, {{ name }}!</h1>" > /tmp/test_template.html
python -c "
from jinja2 import Environment, FileSystemLoader
import os
env = Environment(loader=FileSystemLoader('/tmp'))
template = env.get_template('test_template.html')
result = template.render(name='World')
assert result == '<h1>Hello, World!</h1>', f'Expected \"<h1>Hello, World!</h1>\", got \"{result}\"'
"
rm /tmp/test_template.html

python -c "
from jinja2 import Template, TemplateSyntaxError
try:
Template('{% if %}')
assert False, 'Should have raised TemplateSyntaxError'
except TemplateSyntaxError:
print('Error handling test passed.')
"

# Test 7: Template inheritance
# base template
echo "{% block content %}Default content{% endblock %}" > /tmp/base.html
# child template
echo "{% extends 'base.html' %}{% block content %}Child content{% endblock %}" > /tmp/child.html

python -c "
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader('/tmp'))
template = env.get_template('child.html')
result = template.render()
assert result == 'Child content', f'Expected \"Child content\", got \"{result}\"'
"

rm /tmp/base.html /tmp/child.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

pip install ".[test]"

pytest tests/ -v
20 changes: 20 additions & 0 deletions test/test_artifacts/v2/scripts/run_jupyter_scheduler_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
jupyter_scheduler_version=$(micromamba list | grep jupyter-scheduler | tr -s ' ' | cut -d ' ' -f 3)

git checkout tags/v$jupyter_scheduler_version


pip install ".[test]"

test_files=(
"jupyter_scheduler/tests/test_execution_manager.py"
"jupyter_scheduler/tests/test_handlers.py"
"jupyter_scheduler/tests/test_job_files_manager.py"
"jupyter_scheduler/tests/test_orm.py"
"jupyter_scheduler/tests/test_scheduler.py"
)

for test_file in "${test_files[@]}"; do
echo "Running tests in $test_file"
pytest -v "$test_file"
done
Loading