|
| 1 | +# SPDX-FileCopyrightText: Copyright (c) 2023 - 2026 NVIDIA CORPORATION & AFFILIATES. |
| 2 | +# SPDX-FileCopyrightText: All rights reserved. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +name: Download CI test data |
| 18 | +description: | |
| 19 | + Download PhysicsNeMo CI test data from a private Hugging Face dataset |
| 20 | + repository and export TEST_DATA_DIR for the pytest nfs_data_dir fixture. |
| 21 | +
|
| 22 | +inputs: |
| 23 | + hf-token: |
| 24 | + description: Hugging Face token with read access to the CI data repo |
| 25 | + required: true |
| 26 | + hf-repo: |
| 27 | + description: Hugging Face dataset repo ID |
| 28 | + required: false |
| 29 | + default: "NVIDIA/PhysicsNeMo-CI-Data" |
| 30 | + data-dir: |
| 31 | + description: | |
| 32 | + Parent directory for the downloaded data. The dataset contents land |
| 33 | + in <data-dir>/physicsnemo-data/. Defaults to $RUNNER_TEMP if set, else /tmp. |
| 34 | + required: false |
| 35 | + default: "" |
| 36 | + |
| 37 | +outputs: |
| 38 | + test-data-dir: |
| 39 | + description: The parent directory containing physicsnemo-data/ (set as TEST_DATA_DIR) |
| 40 | + value: ${{ steps.download.outputs.test_data_dir }} |
| 41 | + |
| 42 | +runs: |
| 43 | + using: composite |
| 44 | + steps: |
| 45 | + - name: Download CI test data from Hugging Face |
| 46 | + id: download |
| 47 | + shell: bash |
| 48 | + env: |
| 49 | + HF_TOKEN: ${{ inputs.hf-token }} |
| 50 | + # Needed for Ubuntu 24.04+ containers where system python is |
| 51 | + # externally-managed (PEP 668). |
| 52 | + PIP_BREAK_SYSTEM_PACKAGES: "1" |
| 53 | + run: | |
| 54 | + set -euo pipefail |
| 55 | + data_dir="${{ inputs.data-dir }}" |
| 56 | + if [ -z "$data_dir" ]; then |
| 57 | + data_dir="${RUNNER_TEMP:-/tmp}" |
| 58 | + fi |
| 59 | +
|
| 60 | + if ! command -v huggingface-cli >/dev/null 2>&1; then |
| 61 | + pip install --quiet huggingface_hub[hf_xet] |
| 62 | + fi |
| 63 | + huggingface-cli download "${{ inputs.hf-repo }}" \ |
| 64 | + --repo-type dataset \ |
| 65 | + --local-dir "${data_dir}/physicsnemo-data" \ |
| 66 | + --token "$HF_TOKEN" |
| 67 | +
|
| 68 | + echo "test_data_dir=${data_dir}" >> "$GITHUB_OUTPUT" |
| 69 | + echo "TEST_DATA_DIR=${data_dir}" >> "$GITHUB_ENV" |
| 70 | +
|
| 71 | + # Verify the download produced the expected directory structure. |
| 72 | + # conftest.py resolves TEST_DATA_DIR/physicsnemo-data/datasets/... |
| 73 | + if [ ! -d "${data_dir}/physicsnemo-data/datasets" ]; then |
| 74 | + echo "::error::Expected ${data_dir}/physicsnemo-data/datasets/ but it does not exist." |
| 75 | + echo "Contents of ${data_dir}/physicsnemo-data/:" |
| 76 | + ls -la "${data_dir}/physicsnemo-data/" 2>/dev/null || echo " (directory missing entirely)" |
| 77 | + exit 1 |
| 78 | + fi |
| 79 | + echo "Downloaded CI test data to ${data_dir}/physicsnemo-data/" |
| 80 | + ls "${data_dir}/physicsnemo-data/datasets/" |
0 commit comments