Skip to content

Tests and docs for ability to specify subdirectory to download for LocalizePath #6308

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

Merged
merged 5 commits into from
Sep 20, 2023
Merged
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
46 changes: 46 additions & 0 deletions docs/user_guide/model_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ $ gsutil iam ch allUsers:objectViewer "${BUCKET_URL}"
$ gsutil iam ch allUsers:legacyBucketReader "${BUCKET_URL}"
```

By default, Triton makes a local copy of a remote model repository in
a temporary folder, which is deleted after Triton server is shut down.
If you would like to control where remote model repository is copied to,
you may set the `TRITON_GCS_MOUNT_DIRECTORY` environment variable to
a path pointing to the existing folder on your local machine.

```bash
export TRITON_GCS_MOUNT_DIRECTORY=/path/to/your/local/directory
```

**Make sure, that `TRITON_GCS_MOUNT_DIRECTORY` exists on your local machine
and it is empty.**

#### S3

For a model repository residing in Amazon S3, the path must be
Expand Down Expand Up @@ -177,6 +190,19 @@ If the environment variables are set they will take a higher priority
and will be used by Triton instead of the credentials set using the
aws config command.

By default, Triton makes a local copy of a remote model repository
in a temporary folder, which is deleted after Triton server is shut down.
If you would like to control where remote model repository is copied to,
you may set the `TRITON_AWS_MOUNT_DIRECTORY` environment variable to
Copy link
Contributor

@kthui kthui Sep 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we usually refer to Amazon storage as "S3", so it might be more appropriate to name the environment variable as TRITON_S3_MOUNT_DIRECTORY rather than TRITON_AWS_MOUNT_DIRECTORY.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was mostly inspired by what we use now, and environmental variables were using AWS

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double checking: "AWS" is used on environment variables and "S3" on everywhere else, but the environment variable names (i.e. "AWS_SECRET_ACCESS_KEY") are specified/used by the S3 client initially, so I think it is up to you if you want to use "S3" or "AWS" on the environment variable name.

a path pointing to the existing folder on your local machine.

```bash
export TRITON_AWS_MOUNT_DIRECTORY=/path/to/your/local/directory
```

**Make sure, that `TRITON_AWS_MOUNT_DIRECTORY` exists on your local machine
and it is empty.**

#### Azure Storage

For a model repository residing in Azure Storage, the repository path
Expand All @@ -196,6 +222,19 @@ here's an example of how to find a key corresponding to your `AZURE_STORAGE_ACCO
$ export AZURE_STORAGE_ACCOUNT="account_name"
$ export AZURE_STORAGE_KEY=$(az storage account keys list -n $AZURE_STORAGE_ACCOUNT --query "[0].value")
```
By default, Triton makes a local copy of a remote model repository in
a temporary folder, which is deleted after Triton server is shut down.
If you would like to control where remote model repository is copied to,
you may set the `TRITON_AZURE_MOUNT_DIRECTORY` environment variable to a path
pointing to the existing folder on your local machine.

```bash
export TRITON_AZURE_MOUNT_DIRECTORY=/path/to/your/local/directory
```

**Make sure, that `TRITON_AZURE_MOUNT_DIRECTORY` exists on your local machine
and it is empty.**


### Cloud Storage with Credential file (Beta)

Expand Down Expand Up @@ -258,6 +297,13 @@ If the `TRITON_CLOUD_CREDENTIAL_PATH` environment variable is not set, the
[Cloud Storage with Environment variables](#cloud-storage-with-environment-variables)
will be used.

### Caching of Cloud Storage

Triton currently doesn't perform file caching for cloud storage.
However, this functionality can be implemented through
[repository agent API](https://github.com/triton-inference-server/server/blob/bbbcad7d87adc9596f99e3685da5d6b73380514f/docs/customization_guide/repository_agents.md) by injecting a proxy, which checks a specific local directory for caching
given the cloud storage (original path) of the model,
and then decides if cached files may be used.

## Model Versions

Expand Down
41 changes: 41 additions & 0 deletions qa/L0_storage_S3/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,45 @@ set -e
kill $SERVER_PID
wait $SERVER_PID

# Test localization to a specified location
export TRITON_AWS_MOUNT_DIRECTORY=`pwd`/aws_localization_test

if [ -d "$TRITON_AWS_MOUNT_DIRECTORY" ]; then
rm -rf $TRITON_AWS_MOUNT_DIRECTORY
fi

mkdir -p $TRITON_AWS_MOUNT_DIRECTORY

SERVER_LOG=$SERVER_LOG_BASE.custom_localization.log
SERVER_ARGS="--model-repository=$ROOT_REPO --exit-timeout-secs=120"

run_server
if [ "$SERVER_PID" == "0" ]; then
echo -e "\n***\n*** Failed to start $SERVER\n***"
cat $SERVER_LOG
exit 1
fi

if [ -z "$(ls -A $TRITON_AWS_MOUNT_DIRECTORY)" ]; then
echo -e "\n***\n*** Test localization to a specified location failed. \n***"
echo -e "\n***\n*** Specified mount folder $TRITON_AWS_MOUNT_DIRECTORY is empty \n***"
ls -A $TRITON_AWS_MOUNT_DIRECTORY
exit 1
fi

kill $SERVER_PID
wait $SERVER_PID

if [ -d "$TRITON_AWS_MOUNT_DIRECTORY" ] && [ ! -z "$(ls -A $TRITON_AWS_MOUNT_DIRECTORY)" ]; then
echo -e "\n***\n*** Test localization to a specified location failed. \n***"
echo -e "\n***\n*** Specified mount folder $TRITON_AWS_MOUNT_DIRECTORY was not cleared properly. \n***"
ls -A $TRITON_AWS_MOUNT_DIRECTORY
exit 1
fi

rm -rf $TRITON_AWS_MOUNT_DIRECTORY
unset TRITON_AWS_MOUNT_DIRECTORY

# Save models for AWS_SESSION_TOKEN test
rm -rf tmp_cred_test_models
mv models tmp_cred_test_models
Expand Down Expand Up @@ -357,6 +396,7 @@ aws configure set default.region $AWS_DEFAULT_REGION && \
# Copy models into S3 bucket
aws s3 cp tmp_cred_test_models/ "${BUCKET_URL_SLASH}" --recursive --include "*"

SERVER_LOG=$SERVER_LOG_BASE.temporary_credentials_test.log
SERVER_ARGS="--model-repository=$BUCKET_URL --exit-timeout-secs=120"

run_server
Expand Down Expand Up @@ -389,6 +429,7 @@ wait $SERVER_PID

# Test access decline
export AWS_SECRET_ACCESS_KEY="[Invalid]" && export AWS_SESSION_TOKEN=""
SERVER_LOG=$SERVER_LOG_BASE.access_decline_test.log
SERVER_ARGS="--model-repository=$BUCKET_URL --exit-timeout-secs=120"
run_server
if [ "$SERVER_PID" != "0" ]; then
Expand Down
39 changes: 39 additions & 0 deletions qa/L0_storage_azure/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,45 @@ for ENV_VAR in "shared_key"; do
wait $SERVER_PID
done

# Test localization to a specified location
export TRITON_AZURE_MOUNT_DIRECTORY=`pwd`/azure_localization_test

if [ -d "$TRITON_AZURE_MOUNT_DIRECTORY" ]; then
rm -rf $TRITON_AZURE_MOUNT_DIRECTORY
fi

mkdir -p $TRITON_AZURE_MOUNT_DIRECTORY

SERVER_LOG=$SERVER_LOG_BASE.custom_localization.log
SERVER_ARGS="--model-repository=$MODEL_REPO --exit-timeout-secs=120"

run_server
if [ "$SERVER_PID" == "0" ]; then
echo -e "\n***\n*** Failed to start $SERVER\n***"
cat $SERVER_LOG
exit 1
fi

if [ -z "$(ls -A $TRITON_AZURE_MOUNT_DIRECTORY)" ]; then
echo -e "\n***\n*** Test localization to a specified location failed. \n***"
echo -e "\n***\n*** Specified mount folder $TRITON_AZURE_MOUNT_DIRECTORY is empty \n***"
ls -A $TRITON_AZURE_MOUNT_DIRECTORY
exit 1
fi

kill $SERVER_PID
wait $SERVER_PID

if [ -d "$TRITON_AZURE_MOUNT_DIRECTORY" ] && [ ! -z "$(ls -A $TRITON_AZURE_MOUNT_DIRECTORY)" ]; then
echo -e "\n***\n*** Test localization to a specified location failed. \n***"
echo -e "\n***\n*** Specified mount folder $TRITON_AZURE_MOUNT_DIRECTORY was not cleared properly. \n***"
ls -A $TRITON_AZURE_MOUNT_DIRECTORY
exit 1
fi
Comment on lines +201 to +206
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be misunderstanding, but isn't the point of this feature to deterministically cache cloud storage models/files for re-use across server runs? If we clean it up after server exit, what's the point of picking a specific directory if it can't be re-used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point. The emphasis of the ticket was mostly on specifying the non-random name for the local cache directory. By default, it was mounting to /tmp/folderXXX, so in my understanding, if it is more desirable to mount it to some external space through e.g. /mnt/path/to/external/space. We are cleaning up this directory by default all the time. It is likely that the full feature was vaguely described.


rm -rf $TRITON_AZURE_MOUNT_DIRECTORY
unset TRITON_AZURE_MOUNT_DIRECTORY

# Add test for explicit model control
SERVER_LOG=$SERVER_LOG_BASE.explicit.log
CLIENT_LOG=$CLIENT_LOG_BASE.explicit.log
Expand Down