Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pytorch/torchcodec into mac_wheels_ci
Browse files Browse the repository at this point in the history
  • Loading branch information
scotts committed Oct 3, 2024
2 parents 51010ba + 1fffd02 commit 1e02816
Show file tree
Hide file tree
Showing 23 changed files with 672 additions and 132 deletions.
111 changes: 111 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
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
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
...
2 changes: 1 addition & 1 deletion .github/workflows/cpp_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ jobs:
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
ctest --output-on-failure
popd
4 changes: 3 additions & 1 deletion .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ jobs:
run: python -m pip install --upgrade pip
- name: Install dependencies and FFmpeg
run: |
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
# TODO: torchvision and torchaudio shouldn't be needed. They were only added
# to silence an error as seen in https://github.com/pytorch/torchcodec/issues/203
python -m pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
conda install "ffmpeg=7.0.1" pkg-config -c conda-forge
ffmpeg -version
- name: Build and install torchcodec
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@ jobs:
run: |
python -m pip install pre-commit
- name: Run pre-commit checks
# Continue on error to display the formatting diff in case lint fails.
continue-on-error: true
run: |
pre-commit run --all-files
- name: Check to see what files pre-commit modified
run: |
git diff
mypy:
runs-on: ubuntu-latest
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/macos_wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ jobs:
runner-type: macos-m1-stable
package-name: torchcodec
trigger-event: ${{ github.event_name }}
env-var-script: packaging/wheel_env.sh
build-platform: "python-build-package"
build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python3 -m build --wheel -vvv --no-isolation"

install-and-test:
runs-on: macos-m1-stable
Expand All @@ -75,15 +76,15 @@ jobs:
activate-environment: test
python-version: ${{ matrix.python-version }}
- name: Update pip
run: python -m pip install --upgrade pip
run: python3 -m pip install --upgrade pip
- name: Install PyTorch
run: |
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
python3 -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
- name: Install torchcodec from the wheel
run: |
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
echo Installing $wheel_path
python -m pip install $wheel_path -vvv
python3 -m pip install $wheel_path -vvv
- name: Check out repo
uses: actions/checkout@v3
Expand All @@ -101,9 +102,9 @@ jobs:
- name: Install test dependencies
run: |
python -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
python3 -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
# Ideally we would find a way to get those dependencies from pyproject.toml
python -m pip install numpy pytest pillow
python3 -m pip install numpy pytest pillow
- name: Delete the src/ folder just for fun
run: |
Expand All @@ -121,7 +122,7 @@ jobs:
ls
- name: Smoke test
run: |
python test/decoders/manual_smoke_test.py
python3 test/decoders/manual_smoke_test.py
- name: Run Python tests
run: |
pytest test
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ repos:
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]
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,29 +95,28 @@ ffmpeg -f lavfi -i \
## Installing TorchCodec

Note: if you're on MacOS, you'll need to [build from source](./CONTRIBUTING.md).
Instructions below assume you're on Linux.
The instructions below assume you're on Linux.

First install the latest stable version of PyTorch following the [official
instructions](https://pytorch.org/get-started/locally/).
1. Install the latest stable version of PyTorch following the
[official instructions](https://pytorch.org/get-started/locally/). TorchCodec
requires [PyTorch 2.4](https://pytorch.org/docs/2.4/).

Then:
2. Install FFmpeg, if it's not already installed. Your Linux distribution probably
comes with FFmpeg pre-installed. TorchCodec supports all major FFmpeg versions
in [4, 7].

```bash
pip install torchcodec
```
You will also need FFmpeg installed on your system, and TorchCodec decoding
capabilities are determined by your underlying FFmpeg installation. There are
different options to install FFmpeg e.g.:

```bash
conda install ffmpeg
# or
conda install ffmpeg -c conda-forge
```
If FFmpeg is not already installed, or you need a later version, install it with:

Your Linux distribution probably comes with FFmpeg pre-installed as well.
TorchCodec supports all major FFmpeg version in [4, 7].
```bash
conda install ffmpeg
# or
conda install ffmpeg -c conda-forge
```
3. Install TorchCodec:

```bash
pip install torchcodec
```

## Planned future work

Expand Down
Loading

0 comments on commit 1e02816

Please sign in to comment.