pax_global_header 0000666 0000000 0000000 00000000064 15207546147 0014525 g ustar 00root root 0000000 0000000 52 comment=9f9ed92ae3fd07bb43872acd4ab53953f8e957c3 torchcodec-0.14.0/ 0000775 0000000 0000000 00000000000 15207546147 0013724 5 ustar 00root root 0000000 0000000 torchcodec-0.14.0/.clang-format 0000664 0000000 0000000 00000006260 15207546147 0016303 0 ustar 00root root 0000000 0000000 --- AccessModifierOffset: -1 AlignAfterOpenBracket: AlwaysBreak AlignConsecutiveMacros: false AlignConsecutiveAssignments: false AlignConsecutiveBitFields: false AlignConsecutiveDeclarations: false AlignEscapedNewlines: Left AlignOperands: DontAlign AlignTrailingComments: false AllowAllArgumentsOnNextLine: true AllowAllConstructorInitializersOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: false AllowShortEnumsOnASingleLine: true AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: Empty AllowShortLambdasOnASingleLine: All AllowShortIfStatementsOnASingleLine: Never AllowShortLoopsOnASingleLine: false AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: Yes BinPackArguments: false BinPackParameters: false BreakBeforeBinaryOperators: None BreakBeforeBraces: Attach BreakInheritanceList: BeforeColon BreakBeforeTernaryOperators: true BreakConstructorInitializers: BeforeColon BreakAfterJavaFieldAnnotations: false BreakStringLiterals: false ColumnLimit: 80 CommentPragmas: '^ IWYU pragma:' CompactNamespaces: false ConstructorInitializerAllOnOneLineOrOnePerLine: true ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: true DeriveLineEnding: true DerivePointerAlignment: false DisableFormat: false FixNamespaceComments: true ForEachMacros: - FOR_EACH - FOR_EACH_R - FOR_EACH_RANGE IncludeBlocks: Preserve IncludeCategories: - Regex: '^<.*\.h(pp)?>' Priority: 1 - Regex: '^<.*' Priority: 2 - Regex: '.*' Priority: 3 IndentCaseLabels: true IndentCaseBlocks: false IndentGotoLabels: true IndentPPDirectives: None IndentExternBlock: AfterExternBlock IndentWidth: 2 IndentWrappedFunctionNames: false InsertTrailingCommas: None JavaScriptQuotes: Leave JavaScriptWrapImports: true KeepEmptyLinesAtTheStartOfBlocks: false MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCBinPackProtocolList: Auto ObjCBlockIndentWidth: 2 ObjCBreakBeforeNestedBlockParam: true ObjCSpaceAfterProperty: false ObjCSpaceBeforeProtocolList: false PenaltyBreakAssignment: 2 PenaltyBreakBeforeFirstCallParameter: 1 PenaltyBreakComment: 300 PenaltyBreakFirstLessLess: 120 PenaltyBreakString: 1000 PenaltyBreakTemplateDeclaration: 10 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left ReflowComments: true SeparateDefinitionBlocks: Always SortIncludes: true SortUsingDeclarations: true SpaceAfterCStyleCast: false SpaceAfterLogicalNot: false SpaceAfterTemplateKeyword: true SpaceBeforeAssignmentOperators: true SpaceBeforeCpp11BracedList: false SpaceBeforeCtorInitializerColon: true SpaceBeforeInheritanceColon: true SpaceBeforeParens: ControlStatements SpaceBeforeRangeBasedForLoopColon: true SpaceInEmptyBlock: false SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInConditionalStatement: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false SpacesInSquareBrackets: false SpaceBeforeSquareBrackets: false Standard: Latest TabWidth: 8 UseCRLF: false UseTab: Never ... torchcodec-0.14.0/.flake8 0000664 0000000 0000000 00000000230 15207546147 0015072 0 ustar 00root root 0000000 0000000 [flake8] max-line-length = 120 ignore = E203, E402, W503, W504, F821, E501, B, C4, EXE, E251, E202 per-file-ignores = __init__.py: F401, F403, F405 torchcodec-0.14.0/.github/ 0000775 0000000 0000000 00000000000 15207546147 0015264 5 ustar 00root root 0000000 0000000 torchcodec-0.14.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 15207546147 0017447 5 ustar 00root root 0000000 0000000 torchcodec-0.14.0/.github/ISSUE_TEMPLATE/bug-report.yml 0000664 0000000 0000000 00000003570 15207546147 0022265 0 ustar 00root root 0000000 0000000 name: 🐛 Bug Report description: Create a report to help us reproduce and fix the bug body: - type: markdown attributes: value: > #### Your bug may have already been reported! Please check [the existing and past issues](https://github.com/pytorch/torchcodec/issues?q=sort%3Aupdated-desc+is%3Aissue). - type: textarea attributes: label: 🐛 Describe the bug description: | What broke? What behavior did you see versus what did you expect? Please provide any relevant code, error messages and exception tracebacks. A minimal code example will help us help you faster! The ideal code example is a small chunk of code that we can copy-paste to see the same error you see. For example: ```python # All necessary imports at the beginning import torch import torchcodec from torchcodec.decoders import VideoDecoder # A succinct reproducing example trimmed down to the essential parts: decoder = VideoDecoder("path/to/video.mp4") # Help! This fails! # ... ``` If the code is long, put it in a public gist and link it in the issue: https://gist.github.com. Please also paste any error messages and full exception tracebacks in ```` ```triple quotes blocks``` ````. validations: required: true - type: textarea attributes: label: Versions description: | We support a wide variety of platforms and versions, and many bugs are verison-dependent. Knowing your setup will help us help you faster! Please run the following and paste the output below. ```sh wget https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py # For security purposes, please check the contents of collect_env.py before running it. python collect_env.py ``` validations: required: true - type: markdown attributes: value: > Thanks for contributing 🎉! torchcodec-0.14.0/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000033 15207546147 0021433 0 ustar 00root root 0000000 0000000 blank_issues_enabled: true torchcodec-0.14.0/.github/ISSUE_TEMPLATE/documentation.yml 0000664 0000000 0000000 00000000714 15207546147 0023045 0 ustar 00root root 0000000 0000000 name: 📚 Documentation description: Report an issue related to the TorchCodec documentation body: - type: textarea attributes: label: 📚 The doc issue description: > Is something confusing or wrong? Let us know! Please provide URLs to the content in https://pytorch.org/torchcodec/stable/index.html that you're referring to. validations: required: true - type: markdown attributes: value: > Thanks for contributing 🎉! torchcodec-0.14.0/.github/ISSUE_TEMPLATE/feature-request.yml 0000664 0000000 0000000 00000001037 15207546147 0023314 0 ustar 00root root 0000000 0000000 name: 🚀 Feature request description: Submit a proposal/request for a new TorchCodec feature body: - type: textarea attributes: label: 🚀 The feature description: > What new functionality do you want? validations: required: true - type: textarea attributes: label: Motivation, pitch description: > Why do you want it? If this is related to another GitHub issue, please link that here. validations: required: false - type: markdown attributes: value: > Thanks for contributing 🎉! torchcodec-0.14.0/.github/workflows/ 0000775 0000000 0000000 00000000000 15207546147 0017321 5 ustar 00root root 0000000 0000000 torchcodec-0.14.0/.github/workflows/build_ffmpeg.yaml 0000664 0000000 0000000 00000007731 15207546147 0022640 0 ustar 00root root 0000000 0000000 # Taken and adapted from torchaudio. # Ref: https://github.com/pytorch/audio/blob/main/.github/workflows/ffmpeg.yml # This job is not directly related to regular CI pipeline. # It is intended to create FFmpeg binaries that we upload on S3, # which then will be used during all the build process in CI or local. # # This job does not include the uploading part. # Upload needs to be done manually, and it should be done only once # per new major release of FFmepg. name: Build non-GPL FFmpeg from source on: workflow_dispatch: pull_request: paths: - packaging/build_ffmpeg.sh - .github/workflows/build_ffmpeg.yaml # self reference schedule: - cron: '0 0 * * 0' # on sunday defaults: run: shell: bash -l -eo pipefail {0} jobs: LGPL-Linux-x86_64: strategy: fail-fast: false matrix: ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"] uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.12 permissions: id-token: write contents: read with: job-name: Build upload-artifact: ffmpeg-lgpl-linux_x86_64-${{ matrix.ffmpeg-version }} repository: meta-pytorch/torchcodec script: | export FFMPEG_VERSION="${{ matrix.ffmpeg-version }}" export FFMPEG_ROOT="${PWD}/ffmpeg" packaging/build_ffmpeg.sh tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/linux_x86_64" mkdir -p "${artifact_dir}" mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz" LGPL-Linux-aarch64: strategy: fail-fast: false matrix: ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"] uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.12 permissions: id-token: write contents: read with: job-name: Build upload-artifact: ffmpeg-lgpl-linux_aarch64-${{ matrix.ffmpeg-version }} repository: meta-pytorch/torchcodec runner: linux.arm64.2xlarge docker-image: pytorch/manylinux2_28_aarch64-builder:cpu-aarch64 script: | export FFMPEG_VERSION="${{ matrix.ffmpeg-version }}" export FFMPEG_ROOT="${PWD}/ffmpeg" packaging/build_ffmpeg.sh tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/linux_aarch64" mkdir -p "${artifact_dir}" mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz" LGPL-macOS: strategy: fail-fast: false matrix: ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"] uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.12 with: job-name: Build upload-artifact: ffmpeg-lgpl-macos-${{ matrix.ffmpeg-version }} repository: meta-pytorch/torchcodec runner: macos-14-xlarge script: | export FFMPEG_VERSION="${{ matrix.ffmpeg-version }}" export FFMPEG_ROOT="${PWD}/ffmpeg" packaging/build_ffmpeg.sh tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/lib artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/macos_$(uname -m)" mkdir -p "${artifact_dir}" mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz" LGPL-Windows: strategy: fail-fast: false matrix: ffmpeg-version: ["4.4.4", "5.1.4", "6.1.1", "7.0.1", "8.0"] uses: pytorch/test-infra/.github/workflows/windows_job.yml@release/2.12 with: job-name: Build upload-artifact: ffmpeg-lgpl-windows_x86_64-${{ matrix.ffmpeg-version }} repository: meta-pytorch/torchcodec script: | export FFMPEG_VERSION="${{ matrix.ffmpeg-version }}" export FFMPEG_ROOT="${PWD}/ffmpeg" packaging/build_ffmpeg.bat tar -cf ffmpeg.tar.gz ffmpeg/include ffmpeg/bin artifact_dir="${RUNNER_ARTIFACT_DIR}/$(date +%Y-%m-%d)/windows_$(uname -m)" mkdir -p "${artifact_dir}" mv ffmpeg.tar.gz "${artifact_dir}/${FFMPEG_VERSION}.tar.gz" torchcodec-0.14.0/.github/workflows/cpp_tests.yaml 0000664 0000000 0000000 00000005651 15207546147 0022220 0 ustar 00root root 0000000 0000000 name: CPP tests on: push: branches: [ main ] pull_request: concurrency: group: unit-test${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }} cancel-in-progress: true defaults: run: shell: bash -l -eo pipefail {0} jobs: Cpp-tests: runs-on: ubuntu-latest strategy: fail-fast: false matrix: ffmpeg-version-for-tests: ['7'] steps: - name: Check out repo uses: actions/checkout@v6 - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: '3.12' - name: Update pip run: python -m pip install --upgrade pip - name: Install torch dependencies run: bash packaging/install_pytorch.sh cpu "torch" - name: Install ffmpeg, pkg-config and pybind11 run: | conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" pkg-config pybind11 -c conda-forge ffmpeg -version - name: Build and run C++ tests run: | # Note: we're not setting BUILD_AGAINST_ALL_FFMPEG_FROM_S3 here, so # we're building libtorchcodec against the installed FFmpeg version # (from conda-forge) instead of building against our pre-built non-GPL # FFmpeg libraries. # The reason we need this is because the C++ tests decode x264 files. # x264 support is not LGPL, os it is not supported by our # pre-built non-GPL FFmpeg libraries. And if we were to build against # those, this is also what the tests would be loading at run time, # then failing when we try to decode x264. # To remediate that, we build against the FFmpeg that we installed # from conda-forge (which is able to decode x264), and that's also # what gets loaded at run time. # The Python tests are also decoding x264 files, and are built against # our non-GPL FFmpeg. And yet they pass. This is because in Python # we're able to distinguish between build-time (non-GPL FFmpeg) and # run time (conda-forge FFmpeg). build_tests_dir="${PWD}/build_tests" mkdir $build_tests_dir pushd $build_tests_dir TORCH_PATH=$(python -c "import pathlib, torch; print(pathlib.Path(torch.__path__[0]))") Torch_DIR="${TORCH_PATH}/share/cmake/Torch" cmake .. -DTorch_DIR=$Torch_DIR -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON cmake --build . ctest --output-on-failure popd torchcodec-0.14.0/.github/workflows/lint.yaml 0000664 0000000 0000000 00000004153 15207546147 0021156 0 ustar 00root root 0000000 0000000 name: Lint on: push: branches: [ main ] pull_request: concurrency: group: unit-test${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_number || github.ref }} cancel-in-progress: true defaults: run: shell: bash -l -eo pipefail {0} jobs: pre-commit-checks: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.12'] steps: - name: Check out repo uses: actions/checkout@v6 - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install pre-commit run: | python -m pip install pre-commit - name: Run pre-commit checks run: | pre-commit run --all-files - name: Check to see what files pre-commit modified run: | git diff mypy: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.12'] steps: - name: Check out repo uses: actions/checkout@v6 - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install dependencies and FFmpeg run: | bash packaging/install_pytorch.sh cpu "torch torchvision" conda install "ffmpeg=7.0.1" pkg-config pybind11 -c conda-forge ffmpeg -version - name: Build and install torchcodec run: | python -m pip install -e ".[dev]" --no-build-isolation -vvv - name: Install mypy run: | python -m pip install mypy - name: Run mypy run: | mypy --install-types --non-interactive --config-file mypy.ini torchcodec-0.14.0/.github/workflows/linux_aarch64_wheel.yaml 0000664 0000000 0000000 00000007075 15207546147 0024051 0 ustar 00root root 0000000 0000000 name: Linux CPU aarch64 on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: linux-aarch64 test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-xpu: disable with-rocm: disable with-cuda: disable build-python-only: "disable" build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload Linux aarch64 wheel uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh post-script: packaging/post_build_script.sh smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} architecture: aarch64 build-platform: "python-build-package" build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build --wheel -vvv --no-isolation" install-and-test: runs-on: linux.arm64.2xlarge strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] needs: build steps: - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cpu "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cpu_aarch64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg, post build run: bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python smoke tests run: | pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short - name: Run Python tests if: ${{ matrix.ffmpeg-version-for-tests == '7' && !startsWith(github.ref, 'refs/heads/release/') }} run: | pytest --override-ini="addopts=-v" test torchcodec-0.14.0/.github/workflows/linux_cuda_aarch64_wheel.yaml 0000664 0000000 0000000 00000010220 15207546147 0025027 0 ustar 00root root 0000000 0000000 name: Linux CUDA aarch64 on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: linux-aarch64 test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-cpu: disable with-xpu: disable with-rocm: disable with-cuda: enable build-python-only: "disable" build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload wheel uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh post-script: packaging/post_build_script.sh smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} architecture: aarch64 build-platform: "python-build-package" build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 ENABLE_CUDA=1 python -m build --wheel -vvv --no-isolation" install-and-test: runs-on: linux.arm64.2xlarge strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] cuda-version: ['12.6', '13.0', '13.2'] ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] container: image: "pytorch/manylinuxaarch64-builder:cuda${{ matrix.cuda-version }}" needs: build steps: - name: Setup env vars run: | cuda_version_without_periods=$(echo "${{ matrix.cuda-version }}" | sed 's/\.//g') echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: ${CONDA_RUN} bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cu${{ env.cuda_version_without_periods }}_aarch64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg, post build run: | bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} echo LD_LIBRARY_PATH=$CONDA_PREFIX/lib:/usr/local/cuda/lib64/:${LD_LIBRARY_PATH} >> $GITHUB_ENV - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python smoke tests run: | pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short - name: Run Python tests if: ${{ matrix.ffmpeg-version-for-tests == '8' && !startsWith(github.ref, 'refs/heads/release/') }} run: | pytest --override-ini="addopts=-v" test torchcodec-0.14.0/.github/workflows/linux_cuda_wheel.yaml 0000664 0000000 0000000 00000033210 15207546147 0023523 0 ustar 00root root 0000000 0000000 name: Linux CUDA x86 on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ - v[0-9]+.[0-9]+.[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: linux test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-cpu: disable with-xpu: disable with-rocm: disable with-cuda: enable build-python-only: "disable" build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload wheel uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh post-script: packaging/post_build_script.sh smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} build-platform: "python-build-package" build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 ENABLE_CUDA=1 python -m build --wheel -vvv --no-isolation" install-and-test: runs-on: linux.g5.4xlarge.nvidia.gpu strategy: fail-fast: false matrix: # 3.10 corresponds to the minimum python version for which we build # the wheel unless the label cliflow/binaries/all is present in the # PR. # For the actual release we should add that label and change this to # include more python versions. python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] # We test against 12.6 and 13.0 to avoid having too big of a CI matrix, # but for releases we should add 12.8. cuda-version: ['12.6', '13.0', '13.2'] # TODO: put back ffmpeg 5 https://github.com/pytorch/torchcodec/issues/325 ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] container: image: "pytorch/manylinux2_28-builder:cuda${{ matrix.cuda-version }}" options: "--gpus all -e NVIDIA_DRIVER_CAPABILITIES=video,compute,utility" needs: build steps: - name: Setup env vars run: | cuda_version_without_periods=$(echo "${{ matrix.cuda-version }}" | sed 's/\.//g') echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV python_version_without_periods=$(echo "${{ matrix.python-version }}" | sed 's/\.//g') echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup miniconda using test-infra uses: pytorch/test-infra/.github/actions/setup-miniconda@release/2.12 with: python-version: ${{ matrix.python-version }} # We install conda packages at the start because otherwise conda may have conflicts with dependencies. # Note: xorg-libxau was addded to fix a problem with ffmpeg 4. We should consider removing it. default-packages: "nvidia::cuda-nvrtc=${{ matrix.cuda-version }} nvidia::cuda-toolkit=${{ matrix.cuda-version }} nvidia::cuda-cudart=${{ matrix.cuda-version }} nvidia::cuda-driver-dev=${{ matrix.cuda-version }} conda-forge::ffmpeg=${{ matrix.ffmpeg-version-for-tests }} conda-forge::xorg-libxau" - name: Check env, set LD_LIBRARY_PATH run: | ${CONDA_RUN} env ${CONDA_RUN} conda info ${CONDA_RUN} nvidia-smi ${CONDA_RUN} conda list echo LD_LIBRARY_PATH=$CONDA_PREFIX/lib:/usr/local/cuda/lib64/:${LD_LIBRARY_PATH} >> $GITHUB_ENV - name: Assert ffmpeg exists run: | ${CONDA_RUN} ffmpeg -buildconf - name: Update pip run: ${CONDA_RUN} python -m pip install --upgrade pip - name: Install PyTorch run: | ${CONDA_RUN} bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision" ${CONDA_RUN} python -c 'import torch; print(f"{torch.__version__}"); print(f"{torch.__file__}"); print(f"{torch.cuda.is_available()=}")' - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cu${{ env.cuda_version_without_periods }}_x86_64 path: dist/ - name: Install torchcodec from the wheel run: ${CONDA_RUN} bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl" - name: Install test dependencies run: ${CONDA_RUN} bash packaging/install_test_dependencies.sh - name: Run Python tests run: | ${CONDA_RUN} FAIL_WITHOUT_CUDA=1 pytest --override-ini="addopts=-v" test --tb=short - name: Run Python benchmark run: | ${CONDA_RUN} time python benchmarks/decoders/gpu_benchmark.py --devices=cuda:0,cpu --resize_devices=none install-and-test-on-cpu-only-machine: # This job tests that CUDA wheels work fine on CPU-only machines. Note that # we still install a CUDA-enabled version of torch, and that's by design. # Essentially, what we want to make sure is that # `pip install torch torchcodec` works on CPU-only machines, and this # command should install CUDA-enabled versions of both torch and torchcodec. # It's critical that this job runs on a CPU-only machine. runs-on: ubuntu-latest needs: build env: PYTHON_VERSION: '3.10' CUDA_VERSION: '12.6' FFMPEG_VERSION: '7' steps: - name: Setup env vars run: | cuda_version_without_periods=$(echo "${{ env.CUDA_VERSION }}" | sed 's/\.//g') echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV python_version_without_periods=$(echo "${{ env.PYTHON_VERSION }}" | sed 's/\.//g') echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-version: latest activate-environment: test python-version: ${{ env.PYTHON_VERSION }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ env.PYTHON_VERSION }}_cu${{ env.cuda_version_without_periods }}_x86_64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl" - name: Install ffmpeg run: bash packaging/install_ffmpeg.sh ${{ env.FFMPEG_VERSION }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Assert CUDA is not available run: | python -c "import torch; assert not torch.cuda.is_available()" - name: Run Python tests run: | pytest --override-ini="addopts=-v" test --tb=short build-docs: runs-on: linux.g5.4xlarge.nvidia.gpu env: PYTHON_VERSION: '3.10' CUDA_VERSION: '12.6' FFMPEG_VERSION: '7' container: image: "pytorch/manylinux2_28-builder:cuda12.6" # must be same as env!! options: "--gpus all -e NVIDIA_DRIVER_CAPABILITIES=video,compute,utility" needs: build steps: - name: Setup env vars run: | cuda_version_without_periods=$(echo "${{ env.CUDA_VERSION }}" | sed 's/\.//g') echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV python_version_without_periods=$(echo "${{ env.PYTHON_VERSION }}" | sed 's/\.//g') echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup miniconda using test-infra uses: pytorch/test-infra/.github/actions/setup-miniconda@release/2.12 with: python-version: ${{ env.PYTHON_VERSION }} # We install conda packages at the start because otherwise conda may have conflicts with dependencies. default-packages: "nvidia::cuda-nvrtc=${{ env.CUDA_VERSION }} nvidia::cuda-toolkit=${{ env.CUDA_VERSION }} nvidia::cuda-cudart=${{ env.CUDA_VERSION }} nvidia::cuda-driver-dev=${{ env.CUDA_VERSION }} conda-forge::ffmpeg=${{ env.FFMPEG_VERSION }}" - name: Check env, set LD_LIBRARY_PATH run: | ${CONDA_RUN} env ${CONDA_RUN} conda info ${CONDA_RUN} nvidia-smi ${CONDA_RUN} conda list echo LD_LIBRARY_PATH=$CONDA_PREFIX/lib:/usr/local/cuda/lib64/:${LD_LIBRARY_PATH} >> $GITHUB_ENV - name: Assert ffmpeg exists run: | ${CONDA_RUN} ffmpeg -buildconf - name: Update pip run: ${CONDA_RUN} python -m pip install --upgrade pip - name: Install PyTorch run: | ${CONDA_RUN} bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision" ${CONDA_RUN} python -c 'import torch; print(f"{torch.__version__}"); print(f"{torch.__file__}"); print(f"{torch.cuda.is_available()=}")' - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ env.PYTHON_VERSION }}_cu${{ env.cuda_version_without_periods }}_x86_64 path: dist/ - name: Install torchcodec from the wheel run: ${CONDA_RUN} bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl" - name: Install doc dependencies run: | cd docs ${CONDA_RUN} python -m pip install -r requirements.txt - name: Build docs run: | cd docs ${CONDA_RUN} make html - uses: actions/upload-artifact@v4 with: name: Built-Docs path: docs/build/html/ doc-preview: runs-on: [self-hosted, linux.2xlarge] needs: build-docs if: github.repository == 'meta-pytorch/torchcodec' && github.event_name == 'pull_request' steps: - uses: actions/download-artifact@v4 with: name: Built-Docs path: docs # Update HTML to add the no-index tag so that search engines do not index these ephemeral docs - name: Add no-index tag run: | find docs -name "*.html" -print0 | xargs -0 sed -i '/
/a \ \ '; - name: Upload docs preview uses: seemethere/upload-artifact-s3@v5 with: retention-days: 14 s3-bucket: doc-previews if-no-files-found: error path: docs s3-prefix: meta-pytorch/torchcodec/${{ github.event.pull_request.number }} upload-docs: # This job uploads built docs: # - to the `main` folder of the gh-pages branch (https://meta-pytorch.org/torchcodec/main) on every commit to the `main` branch # - to the (e.g.) `0.10` folder in the gh-pages branch whenever a corresponding tag is pushed, like `v0.10.0` (https://meta-pytorch.org/torchcodec/0.10). needs: build-docs if: github.repository == 'meta-pytorch/torchcodec' && github.event_name == 'push' && ((github.ref_type == 'branch' && github.ref_name == 'main') || github.ref_type == 'tag') runs-on: ubuntu-latest steps: - name: Check out gh-pages branch uses: actions/checkout@v6 with: ref: gh-pages - uses: actions/download-artifact@v4 with: name: Built-Docs path: docs-artifact/ - name: Update docs and push run: | set -euo pipefail REF_TYPE=${{ github.ref_type }} REF_NAME=${{ github.ref_name }} if [[ "${REF_TYPE}" == branch ]]; then TARGET_FOLDER="${REF_NAME}" elif [[ "${REF_TYPE}" == tag ]]; then case "${REF_NAME}" in *-rc*) echo "Aborting upload since this is an RC tag: ${REF_NAME}" exit 0 ;; *) # Strip the leading "v" as well as the trailing patch version. For example: # 'v0.10.2' -> '0.10' TARGET_FOLDER=$(echo "${REF_NAME}" | sed 's/v\([0-9]\+\)\.\([0-9]\+\)\.[0-9]\+/\1.\2/') ;; esac fi echo "Target Folder: ${TARGET_FOLDER}" mkdir -p "${TARGET_FOLDER}" rm -rf "${TARGET_FOLDER}"/* cp -r docs-artifact/* "${TARGET_FOLDER}/" git add "${TARGET_FOLDER}" git config user.name 'pytorchbot' git config user.email 'soumith+bot@pytorch.org' git commit -m "auto-generating sphinx docs for ${TARGET_FOLDER}" || echo "No changes to commit" git push torchcodec-0.14.0/.github/workflows/linux_wheel.yaml 0000664 0000000 0000000 00000012153 15207546147 0022532 0 ustar 00root root 0000000 0000000 name: Linux CPU x86 on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: linux test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-xpu: disable with-rocm: disable with-cuda: disable build-python-only: "disable" build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload wheel uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh post-script: packaging/post_build_script.sh smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} build-platform: "python-build-package" build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build --wheel -vvv --no-isolation" also-upload-to-gpu-arch-versions: "xpu" install-and-test: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] needs: build steps: - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cpu "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cpu_x86_64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg, post build run: bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python tests run: | pytest --override-ini="addopts=-v" test install-and-test-third-party-interface: runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] needs: build steps: - name: Check out repo uses: actions/checkout@v3 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cpu "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cpu_x86_64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg, post build run: bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} - name: Install pkg-config run: | conda install pkg-config -c conda-forge - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python tests run: | pytest --override-ini="addopts=-v" test/third-party-interface torchcodec-0.14.0/.github/workflows/macos_wheel.yaml 0000664 0000000 0000000 00000007217 15207546147 0022502 0 ustar 00root root 0000000 0000000 name: MacOS on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: macos-arm64 test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-xpu: disable with-rocm: disable with-cuda: disable build-python-only: "disable" python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload wheel uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh post-script: packaging/post_build_script.sh smoke-test-script: packaging/fake_smoke_test.py runner-type: macos-14 setup-miniconda: true package-name: torchcodec trigger-event: ${{ github.event_name }} build-platform: "python-build-package" build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build --wheel -vvv --no-isolation" install-and-test: runs-on: macos-14-xlarge strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] needs: build steps: - name: Check out torchcodec repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cpu "torch torchvision" - name: Download wheel uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cpu_ path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg run: bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python smoke tests run: | pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short - name: Run Python tests if: ${{ matrix.ffmpeg-version-for-tests == '8' && !startsWith(github.ref, 'refs/heads/release/') }} run: | pytest --override-ini="addopts=-v" test torchcodec-0.14.0/.github/workflows/reference_resources.yaml 0000664 0000000 0000000 00000005647 15207546147 0024251 0 ustar 00root root 0000000 0000000 name: Reference resource generation tests on: workflow_dispatch: pull_request: paths: - test/generate_reference_resources.py - .github/workflows/reference_resources.yaml # self reference schedule: - cron: '0 0 * * 0' # on sunday defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: linux test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-xpu: disable with-rocm: disable with-cuda: disable build-python-only: "disable" build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload Linux wheel uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh post-script: packaging/post_build_script.sh smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} build-platform: "python-build-package" build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python -m build --wheel -vvv --no-isolation" test-reference-resource-generation: needs: build runs-on: ubuntu-latest strategy: fail-fast: false matrix: python-version: ['3.10'] # Traditionally we generate the resources locally on FFmpeg 4 or 6. # The exact version shouln't matter as long as the unit tests pass # across all version for a given generated resource. ffmpeg-version-for-tests: ['6'] steps: - name: Check out repo uses: actions/checkout@v3 - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cpu "torch" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cpu_x86_64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg, post build run: bash packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run generation reference resources run: | python -m test.generate_reference_resources torchcodec-0.14.0/.github/workflows/windows_cuda_wheel.yaml 0000664 0000000 0000000 00000017342 15207546147 0024066 0 ustar 00root root 0000000 0000000 name: Windows CUDA on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: windows test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-cpu: disable with-xpu: disable with-rocm: disable with-cuda: enable build-python-only: "disable" python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload wheel uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh # post-script: packaging/post_build_script.sh TODO: consider enabling post-build checks for Windows env-script: packaging/vc_env_helper.bat smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} build-platform: "python-build-package" # The BUILD_AGAINST_ALL_FFMPEG_FROM_S3 and ENABLE_CUDA vars, needed to # build the wheel, are set in vc_env_helper.bat. Couldn't find a way to # set them from here. build-command: "python -m build --wheel -vvv --no-isolation" install-and-test: runs-on: windows.g5.4xlarge.nvidia.gpu strategy: fail-fast: false matrix: # 3.10 corresponds to the minimum python version for which we build # the wheel unless the label cliflow/binaries/all is present in the # PR. # For the actual release we should add that label and change this to # include more python versions. python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] cuda-version: ['12.6', '13.0', '13.2'] # TODO: FFmpeg 5 on Windows segfaults in avcodec_open2() when passing # bad parameters. # See https://github.com/pytorch/torchcodec/pull/806 ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] needs: build steps: - name: Setup env vars run: | cuda_version_without_periods=$(echo "${{ matrix.cuda-version }}" | sed 's/\.//g') echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV python_version_without_periods=$(echo "${{ matrix.python-version }}" | sed 's/\.//g') echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV - name: Check out repo uses: actions/checkout@v6 - name: Update NVIDIA driver uses: pytorch/test-infra/.github/actions/setup-nvidia-windows@release/2.12 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Install CUDA and FFmpeg conda packages run: | conda install -y \ "nvidia::cuda-nvrtc=${{ matrix.cuda-version }}" \ "nvidia::cuda-cudart=${{ matrix.cuda-version }}" \ "conda-forge::ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" - name: Check env run: | env conda info conda list - name: Assert ffmpeg exists run: | ffmpeg -buildconf - name: Check FFmpeg CUDA support run: | ffmpeg -decoders | grep -i nvidia - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: | bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision" python -c 'import torch; print(f"{torch.__version__}"); print(f"{torch.__file__}"); print(f"{torch.cuda.is_available()=}")' - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cu${{ env.cuda_version_without_periods }}_x64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl" - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python tests run: | FAIL_WITHOUT_CUDA=1 pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short - name: Run Python benchmark run: | time python benchmarks/decoders/gpu_benchmark.py --devices=cuda:0,cpu --resize_devices=none install-and-test-on-cpu-only-machine: # This job tests that CUDA wheels work fine on CPU-only machines. Note that # we still install a CUDA-enabled version of torch, and that's by design. # Essentially, what we want to make sure is that # `pip install torch torchcodec` works on CPU-only machines, and this # command should install CUDA-enabled versions of both torch and torchcodec. # It's critical that this job runs on a CPU-only machine. runs-on: windows-latest needs: build env: PYTHON_VERSION: '3.10' CUDA_VERSION: '12.6' FFMPEG_VERSION: '7' steps: - name: Setup env vars run: | cuda_version_without_periods=$(echo "${{ env.CUDA_VERSION }}" | sed 's/\.//g') echo cuda_version_without_periods=${cuda_version_without_periods} >> $GITHUB_ENV python_version_without_periods=$(echo "${{ env.PYTHON_VERSION }}" | sed 's/\.//g') echo python_version_without_periods=${python_version_without_periods} >> $GITHUB_ENV - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true miniforge-version: latest activate-environment: test python-version: ${{ env.PYTHON_VERSION }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cu${{ env.cuda_version_without_periods }} "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ env.PYTHON_VERSION }}_cu${{ env.cuda_version_without_periods }}_x64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh "*cu${{ env.cuda_version_without_periods }}-cp${{ env.python_version_without_periods }}*.whl" - name: Install ffmpeg run: bash -l packaging/install_ffmpeg.sh ${{ env.FFMPEG_VERSION }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Assert CUDA is not available run: | python -c "import torch; assert not torch.cuda.is_available()" - name: Run Python tests run: | pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short torchcodec-0.14.0/.github/workflows/windows_wheel.yaml 0000664 0000000 0000000 00000007762 15207546147 0023077 0 ustar 00root root 0000000 0000000 name: Windows CPU on: pull_request: push: branches: - nightly - main - release/* tags: - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref_name }}-${{ github.ref_type == 'branch' && github.sha }}-${{ github.event_name == 'workflow_dispatch' }} cancel-in-progress: true permissions: id-token: write contents: write defaults: run: shell: bash -l -eo pipefail {0} jobs: generate-matrix: uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.12 with: package-type: wheel os: windows test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 with-xpu: disable with-rocm: disable with-cuda: disable build-python-only: "disable" python-versions: '["3.10", "3.11", "3.12", "3.13", "3.14"]' build: needs: generate-matrix strategy: fail-fast: false name: Build and Upload wheel uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@release/2.12 with: repository: meta-pytorch/torchcodec ref: "" test-infra-repository: pytorch/test-infra test-infra-ref: release/2.12 build-matrix: ${{ needs.generate-matrix.outputs.matrix }} pre-script: packaging/pre_build_script.sh # post-script: packaging/post_build_script.sh TODO: consider enabling post-build checks for Windows env-script: packaging/vc_env_helper.bat smoke-test-script: packaging/fake_smoke_test.py package-name: torchcodec trigger-event: ${{ github.event_name }} build-platform: "python-build-package" # The BUILD_AGAINST_ALL_FFMPEG_FROM_S3 var, needed to build the wheel, is # set in vc_env_helper.bat Couldn't find a way to set it from here. build-command: "python -m build --wheel -vvv --no-isolation" install-and-test: runs-on: windows-latest strategy: fail-fast: false matrix: python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] # TODO: FFmpeg 5 on Windows segfaults in avcodec_open2() when passing # bad parameters. # See https://github.com/pytorch/torchcodec/pull/806 ffmpeg-version-for-tests: ['4', '5', '6', '7', '8'] needs: build steps: - name: Check out repo uses: actions/checkout@v6 - name: Remove src/ folder run: bash packaging/remove_src.sh - name: Setup conda env uses: conda-incubator/setup-miniconda@v3 with: auto-update-conda: true # Using miniforge instead of miniconda ensures that the default # conda channel is conda-forge instead of main/default. This ensures # ABI consistency between dependencies: # https://conda-forge.org/docs/user/transitioning_from_defaults/ miniforge-version: latest activate-environment: test python-version: ${{ matrix.python-version }} - name: Update pip run: python -m pip install --upgrade pip - name: Install PyTorch run: bash packaging/install_pytorch.sh cpu "torch torchvision" - uses: actions/download-artifact@v4 with: name: meta-pytorch_torchcodec__${{ matrix.python-version }}_cpu_x64 path: dist/ - name: Install torchcodec from the wheel run: bash packaging/install_torchcodec_wheel.sh - name: Install ffmpeg, post build # need -l for conda to be exposed run: bash -l packaging/install_ffmpeg.sh ${{ matrix.ffmpeg-version-for-tests }} - name: Install test dependencies run: bash packaging/install_test_dependencies.sh - name: Run Python smoke tests run: | pytest --override-ini="addopts=-v" test/smoke_test.py --tb=short - name: Run Python tests if: ${{ matrix.ffmpeg-version-for-tests == '8' && !startsWith(github.ref, 'refs/heads/release/') }} run: | pytest --override-ini="addopts=-v" test torchcodec-0.14.0/.gitignore 0000664 0000000 0000000 00000001134 15207546147 0015713 0 ustar 00root root 0000000 0000000 build/ dist/ src/TorchCodec.egg-info/ */**/__pycache__ */__pycache__ */*.pyc */**/*.pyc */**/**/*.pyc */**/*~ *~ frame180.* # output from smoke test src/torchcodec/version.py docs/build # sphinx-gallery docs/source/generated_examples/ docs/source/gen_modules/ docs/source/generated/ docs/source/models/generated/ docs/source/sg_execution_times.rst # pytorch-sphinx-theme gets installed here docs/src .coverage htmlcov .*.swp *.so* *.dylib* */*.so* */*.dylib* *.swp *.swo gen.yml .mypy_cache .vscode/ .idea/ *.orig *-checkpoint.ipynb *.venv ## Xcode User settings xcuserdata/ # direnv .direnv .envrc torchcodec-0.14.0/.pre-commit-config.yaml 0000664 0000000 0000000 00000002074 15207546147 0020210 0 ustar 00root root 0000000 0000000 repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - id: check-docstring-first - id: trailing-whitespace - id: check-toml - id: check-yaml args: - --allow-multiple-documents - id: mixed-line-ending args: [--fix=lf] - id: end-of-file-fixer - id: check-added-large-files args: ['--maxkb=1000'] - repo: https://github.com/asottile/pyupgrade rev: v3.21.2 hooks: - id: pyupgrade args: [--py310-plus] files: ^(test|src)/ exclude: ^examples/ - repo: https://github.com/omnilib/ufmt rev: v2.6.0 hooks: - id: ufmt additional_dependencies: - black == 24.4.2 - usort == 1.0.5 - repo: https://github.com/PyCQA/flake8 rev: 7.1.0 hooks: - id: flake8 args: [--config=.flake8] - repo: https://github.com/pre-commit/mirrors-clang-format rev: v18.1.3 hooks: - id: clang-format name: clang-format files: \.(cpp|hpp|c|h)$ types: [file] torchcodec-0.14.0/CMakeLists.txt 0000664 0000000 0000000 00000000514 15207546147 0016464 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.18) project(TorchCodec) # Define LINUX platform variable globally if (UNIX AND NOT APPLE) set(LINUX TRUE) else() set(LINUX FALSE) endif() add_subdirectory(src/torchcodec/_core) option(BUILD_TESTS "Build tests" OFF) if(BUILD_TESTS) enable_testing() add_subdirectory(test) endif() torchcodec-0.14.0/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000006417 15207546147 0016533 0 ustar 00root root 0000000 0000000 # Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies within all project spaces, and it also applies when an individual is representing the project or its community in public spaces. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at