Skip to content

Commit 1e02816

Browse files
committed
Merge branch 'main' of github.com:pytorch/torchcodec into mac_wheels_ci
2 parents 51010ba + 1fffd02 commit 1e02816

23 files changed

+672
-132
lines changed

.clang-format

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveMacros: false
5+
AlignConsecutiveAssignments: false
6+
AlignConsecutiveBitFields: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Left
9+
AlignOperands: DontAlign
10+
AlignTrailingComments: false
11+
AllowAllArgumentsOnNextLine: true
12+
AllowAllConstructorInitializersOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: false
14+
AllowShortEnumsOnASingleLine: true
15+
AllowShortBlocksOnASingleLine: Never
16+
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortFunctionsOnASingleLine: Empty
18+
AllowShortLambdasOnASingleLine: All
19+
AllowShortIfStatementsOnASingleLine: Never
20+
AllowShortLoopsOnASingleLine: false
21+
AlwaysBreakAfterReturnType: None
22+
AlwaysBreakBeforeMultilineStrings: true
23+
AlwaysBreakTemplateDeclarations: Yes
24+
BinPackArguments: false
25+
BinPackParameters: false
26+
BreakBeforeBinaryOperators: None
27+
BreakBeforeBraces: Attach
28+
BreakInheritanceList: BeforeColon
29+
BreakBeforeTernaryOperators: true
30+
BreakConstructorInitializers: BeforeColon
31+
BreakAfterJavaFieldAnnotations: false
32+
BreakStringLiterals: false
33+
ColumnLimit: 80
34+
CommentPragmas: '^ IWYU pragma:'
35+
CompactNamespaces: false
36+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
37+
ConstructorInitializerIndentWidth: 4
38+
ContinuationIndentWidth: 4
39+
Cpp11BracedListStyle: true
40+
DeriveLineEnding: true
41+
DerivePointerAlignment: false
42+
DisableFormat: false
43+
FixNamespaceComments: true
44+
ForEachMacros:
45+
- FOR_EACH
46+
- FOR_EACH_R
47+
- FOR_EACH_RANGE
48+
IncludeBlocks: Preserve
49+
IncludeCategories:
50+
- Regex: '^<.*\.h(pp)?>'
51+
Priority: 1
52+
- Regex: '^<.*'
53+
Priority: 2
54+
- Regex: '.*'
55+
Priority: 3
56+
IndentCaseLabels: true
57+
IndentCaseBlocks: false
58+
IndentGotoLabels: true
59+
IndentPPDirectives: None
60+
IndentExternBlock: AfterExternBlock
61+
IndentWidth: 2
62+
IndentWrappedFunctionNames: false
63+
InsertTrailingCommas: None
64+
JavaScriptQuotes: Leave
65+
JavaScriptWrapImports: true
66+
KeepEmptyLinesAtTheStartOfBlocks: false
67+
MacroBlockBegin: ''
68+
MacroBlockEnd: ''
69+
MaxEmptyLinesToKeep: 1
70+
NamespaceIndentation: None
71+
ObjCBinPackProtocolList: Auto
72+
ObjCBlockIndentWidth: 2
73+
ObjCBreakBeforeNestedBlockParam: true
74+
ObjCSpaceAfterProperty: false
75+
ObjCSpaceBeforeProtocolList: false
76+
PenaltyBreakAssignment: 2
77+
PenaltyBreakBeforeFirstCallParameter: 1
78+
PenaltyBreakComment: 300
79+
PenaltyBreakFirstLessLess: 120
80+
PenaltyBreakString: 1000
81+
PenaltyBreakTemplateDeclaration: 10
82+
PenaltyExcessCharacter: 1000000
83+
PenaltyReturnTypeOnItsOwnLine: 200
84+
PointerAlignment: Left
85+
ReflowComments: true
86+
SortIncludes: true
87+
SortUsingDeclarations: true
88+
SpaceAfterCStyleCast: false
89+
SpaceAfterLogicalNot: false
90+
SpaceAfterTemplateKeyword: true
91+
SpaceBeforeAssignmentOperators: true
92+
SpaceBeforeCpp11BracedList: false
93+
SpaceBeforeCtorInitializerColon: true
94+
SpaceBeforeInheritanceColon: true
95+
SpaceBeforeParens: ControlStatements
96+
SpaceBeforeRangeBasedForLoopColon: true
97+
SpaceInEmptyBlock: false
98+
SpaceInEmptyParentheses: false
99+
SpacesBeforeTrailingComments: 1
100+
SpacesInAngles: false
101+
SpacesInConditionalStatement: false
102+
SpacesInContainerLiterals: true
103+
SpacesInCStyleCastParentheses: false
104+
SpacesInParentheses: false
105+
SpacesInSquareBrackets: false
106+
SpaceBeforeSquareBrackets: false
107+
Standard: Latest
108+
TabWidth: 8
109+
UseCRLF: false
110+
UseTab: Never
111+
...

.github/workflows/cpp_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@ jobs:
6565
Torch_DIR="${TORCH_PATH}/share/cmake/Torch"
6666
cmake .. -DTorch_DIR=$Torch_DIR -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON -DCMAKE_VERBOSE_MAKEFILE=ON
6767
cmake --build .
68-
ctest
68+
ctest --output-on-failure
6969
popd

.github/workflows/docs.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ jobs:
2828
run: python -m pip install --upgrade pip
2929
- name: Install dependencies and FFmpeg
3030
run: |
31-
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
31+
# TODO: torchvision and torchaudio shouldn't be needed. They were only added
32+
# to silence an error as seen in https://github.com/pytorch/torchcodec/issues/203
33+
python -m pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
3234
conda install "ffmpeg=7.0.1" pkg-config -c conda-forge
3335
ffmpeg -version
3436
- name: Build and install torchcodec

.github/workflows/lint.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ jobs:
3636
run: |
3737
python -m pip install pre-commit
3838
- name: Run pre-commit checks
39+
# Continue on error to display the formatting diff in case lint fails.
40+
continue-on-error: true
3941
run: |
4042
pre-commit run --all-files
43+
- name: Check to see what files pre-commit modified
44+
run: |
45+
git diff
4146
4247
mypy:
4348
runs-on: ubuntu-latest

.github/workflows/macos_wheel.yaml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ jobs:
5151
runner-type: macos-m1-stable
5252
package-name: torchcodec
5353
trigger-event: ${{ github.event_name }}
54-
env-var-script: packaging/wheel_env.sh
54+
build-platform: "python-build-package"
55+
build-command: "BUILD_AGAINST_ALL_FFMPEG_FROM_S3=1 python3 -m build --wheel -vvv --no-isolation"
5556

5657
install-and-test:
5758
runs-on: macos-m1-stable
@@ -75,15 +76,15 @@ jobs:
7576
activate-environment: test
7677
python-version: ${{ matrix.python-version }}
7778
- name: Update pip
78-
run: python -m pip install --upgrade pip
79+
run: python3 -m pip install --upgrade pip
7980
- name: Install PyTorch
8081
run: |
81-
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
82+
python3 -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
8283
- name: Install torchcodec from the wheel
8384
run: |
8485
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
8586
echo Installing $wheel_path
86-
python -m pip install $wheel_path -vvv
87+
python3 -m pip install $wheel_path -vvv
8788
8889
- name: Check out repo
8990
uses: actions/checkout@v3
@@ -101,9 +102,9 @@ jobs:
101102
102103
- name: Install test dependencies
103104
run: |
104-
python -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
105+
python3 -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
105106
# Ideally we would find a way to get those dependencies from pyproject.toml
106-
python -m pip install numpy pytest pillow
107+
python3 -m pip install numpy pytest pillow
107108
108109
- name: Delete the src/ folder just for fun
109110
run: |
@@ -121,7 +122,7 @@ jobs:
121122
ls
122123
- name: Smoke test
123124
run: |
124-
python test/decoders/manual_smoke_test.py
125+
python3 test/decoders/manual_smoke_test.py
125126
- name: Run Python tests
126127
run: |
127128
pytest test

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,11 @@ repos:
2727
hooks:
2828
- id: flake8
2929
args: [--config=.flake8]
30+
31+
- repo: https://github.com/pre-commit/mirrors-clang-format
32+
rev: v18.1.3
33+
hooks:
34+
- id: clang-format
35+
name: clang-format
36+
files: \.(cpp|hpp|c|h)$
37+
types: [file]

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,28 @@ ffmpeg -f lavfi -i \
9595
## Installing TorchCodec
9696

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

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

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

105-
```bash
106-
pip install torchcodec
107-
```
108-
You will also need FFmpeg installed on your system, and TorchCodec decoding
109-
capabilities are determined by your underlying FFmpeg installation. There are
110-
different options to install FFmpeg e.g.:
111-
112-
```bash
113-
conda install ffmpeg
114-
# or
115-
conda install ffmpeg -c conda-forge
116-
```
108+
If FFmpeg is not already installed, or you need a later version, install it with:
117109

118-
Your Linux distribution probably comes with FFmpeg pre-installed as well.
119-
TorchCodec supports all major FFmpeg version in [4, 7].
110+
```bash
111+
conda install ffmpeg
112+
# or
113+
conda install ffmpeg -c conda-forge
114+
```
115+
3. Install TorchCodec:
120116

117+
```bash
118+
pip install torchcodec
119+
```
121120

122121
## Planned future work
123122

0 commit comments

Comments
 (0)