From 0798121f8d91d95a3f83cafa0fefb3e7e9252c25 Mon Sep 17 00:00:00 2001 From: ShawnXuan Date: Sun, 11 Aug 2024 20:49:36 +0800 Subject: [PATCH] support 3rd party test --- test/Dockerfile | 12 +++++++++ test/README.md | 14 ++++++++++ test/build.sh | 5 ++++ test/cv_cls_test.sh | 58 +++++++++++++++++++++++++++++++++++++++++ test/cv_det_test.sh | 60 +++++++++++++++++++++++++++++++++++++++++++ test/launch.sh | 21 +++++++++++++++ test/requirements.txt | 11 ++++++++ 7 files changed, 181 insertions(+) create mode 100644 test/Dockerfile create mode 100644 test/README.md create mode 100755 test/build.sh create mode 100755 test/cv_cls_test.sh create mode 100755 test/cv_det_test.sh create mode 100755 test/launch.sh create mode 100644 test/requirements.txt diff --git a/test/Dockerfile b/test/Dockerfile new file mode 100644 index 0000000..227933d --- /dev/null +++ b/test/Dockerfile @@ -0,0 +1,12 @@ +FROM oneflowinc/oneflow:0.9.1.dev20240203-cuda11.8 + +RUN python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple + +COPY requirements.txt /tmp/requirements.txt +RUN python3 -m pip install --no-cache-dir -r /tmp/requirements.txt + +RUN python3 -m pip install --pre oneflow -f https://oneflow-staging.oss-cn-beijing.aliyuncs.com/branch/master/cu118 + +WORKDIR /workspace + +RUN rm /tmp/requirements.txt diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..9412e5a --- /dev/null +++ b/test/README.md @@ -0,0 +1,14 @@ +## cv_cls_test.sh + +### 介绍 +`cv_cls_test.sh` 是一个用于处理 `cv/classification` 目录下子目录的 Bash 脚本。根据用户提供的参数,该脚本可以对所有子目录、随机选取的子目录或前 n 个子目录进行操作。 + +### 脚本功能 +1. **复制子目录**:将指定的子目录内容复制到 `/workspace/temp_model` 目录下。 +2. **进入工作目录**:进入 `/workspace/temp_model` 目录。 +3. **运行脚本**:执行该目录下的脚本(`infer.sh`缺省脚本)。 + +### 使用方法 + +```bash +./cv_cls_test.sh {all|random|n} {infer.sh|train.sh} diff --git a/test/build.sh b/test/build.sh new file mode 100755 index 0000000..5357134 --- /dev/null +++ b/test/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +IMAGE_NAME="oneflow_comodels_test:0.1" + +docker build -t $IMAGE_NAME . + diff --git a/test/cv_cls_test.sh b/test/cv_cls_test.sh new file mode 100755 index 0000000..0ef1761 --- /dev/null +++ b/test/cv_cls_test.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +EXEC=${2:-infer.sh} +SUB_DIR_PATH="/workspace/CoModels/cv/classification" +WORKSPACE="/workspace/temp_model" + +if [ $# -ne 1 ]; then + echo "Usage: $0 {all|random|n}" + exit 1 +fi + +option="$1" + +subdirs=($(find "$SUB_DIR_PATH" -mindepth 1 -maxdepth 1 -type d)) + +process_subdir() { + local dir="$1" + + rm -rf "$WORKSPACE" + mkdir -p "$WORKSPACE" + + cp -rL "$dir"/* "$WORKSPACE" + + cd "$WORKSPACE" + + if [ -f "./$EXEC" ]; then + bash ./$EXEC + else + echo "$EXEC not found in $WORKSPACE" + fi + + cd - > /dev/null +} + +case "$option" in + "all") + for dir in "${subdirs[@]}"; do + process_subdir "$dir" + done + ;; + "random") + random_index=$((RANDOM % ${#subdirs[@]})) + process_subdir "${subdirs[$random_index]}" + ;; + [0-9]*) + n="$option" + for ((i=0; i /dev/null +} + +case "$option" in + "all") + for dir in "${subdirs[@]}"; do + process_subdir "$dir" + done + ;; + "random") + random_index=$((RANDOM % ${#subdirs[@]})) + process_subdir "${subdirs[$random_index]}" + ;; + [0-9]*) + n="$option" + for ((i=0; i