Skip to content

Commit 571ed17

Browse files
committed
Change logging
1 parent b639a46 commit 571ed17

File tree

4 files changed

+29
-144
lines changed

4 files changed

+29
-144
lines changed

.github/workflows/linux_wheel.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test Linux wheels
1+
name: Build and test Linux wheel
22

33
on:
44
pull_request:
@@ -24,6 +24,7 @@ defaults:
2424
shell: bash -l -eo pipefail {0}
2525

2626
jobs:
27+
2728
generate-matrix:
2829
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
2930
with:
@@ -34,6 +35,8 @@ jobs:
3435
with-xpu: disable
3536
with-rocm: disable
3637
with-cuda: disable
38+
build-python-only: "disable"
39+
3740
build:
3841
needs: generate-matrix
3942
strategy:
@@ -60,7 +63,6 @@ jobs:
6063
matrix:
6164
python-version: ['3.9']
6265
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
63-
if: ${{ always() }}
6466
needs: build
6567
steps:
6668
- uses: actions/download-artifact@v3
@@ -121,7 +123,7 @@ jobs:
121123
ls
122124
- name: Smoke test
123125
run: |
124-
python test/decoders/manual_smoke_test.py
126+
python -X faulthandler test/decoders/manual_smoke_test.py
125127
- name: Run Python tests
126128
run: |
127129
pytest test -vvv

.github/workflows/macos_wheel.yaml

Lines changed: 24 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and test MacOS wheels
1+
name: Build and test MacOS wheel
22

33
on:
44
pull_request:
@@ -24,6 +24,7 @@ defaults:
2424
shell: bash -l -eo pipefail {0}
2525

2626
jobs:
27+
2728
generate-matrix:
2829
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@macbuildwheel
2930
with:
@@ -34,6 +35,8 @@ jobs:
3435
with-xpu: disable
3536
with-rocm: disable
3637
with-cuda: disable
38+
build-python-only: "disable"
39+
3740
build:
3841
needs: generate-matrix
3942
strategy:
@@ -61,134 +64,47 @@ jobs:
6164
matrix:
6265
python-version: ['3.9']
6366
ffmpeg-version-for-tests: ['4.4.2', '5.1.2', '6.1.1', '7.0.1']
64-
if: ${{ always() }}
6567
needs: build
6668
steps:
67-
- name: Setup miniconda
68-
uses: pytorch/test-infra/.github/actions/setup-miniconda@macbuildwheel
69-
with:
70-
python-version: ${{ matrix.python-version }}
71-
- name: Check out torchcodec repo
72-
uses: actions/checkout@v3
73-
- name: Check out tet-infra repo
74-
uses: actions/checkout@v3
75-
with:
76-
repository: pytorch/test-infra
77-
ref: macbuildwheel
78-
path: test-infra
7969
- name: Download wheel
8070
uses: actions/download-artifact@v3
8171
with:
8272
name: pytorch_torchcodec__${{ matrix.python-version }}_cpu_
8373
path: pytorch/torchcodec/dist/
84-
85-
## start copying from test-infra/.github/actions/setup-binary-builds/action.yaml
86-
- name: Clean conda environment
87-
shell: bash -l {0}
88-
run: |
89-
set -euxo pipefail
90-
conda info | grep -i 'base environment'
91-
conda clean --all --quiet --yes
92-
- name: Reset channel priority
93-
shell: bash -l {0}
94-
run: |
95-
set -euxo pipefail
96-
conda config --set channel_priority false
97-
- name: Discover dir structure
98-
shell: bash -l {0}
99-
run: |
100-
echo "pwd"
101-
pwd
102-
echo "ls -lh"
103-
ls -lh
104-
echo "ls -lh pytorch/torchcodec"
105-
ls -lh pytorch/torchcodec
106-
echo "ls -lh pytorch/torchcodec/dist"
107-
ls -lh pytorch/torchcodec/dist
108-
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
109-
echo "unzip $wheel_path -d unzipped_wheel"
110-
unzip $wheel_path -d unzipped_wheel
111-
echo "ls -lh unzipped_wheel"
112-
ls -lh unzipped_wheel
113-
- name: Generate file from pytorch_pkg_helpers
114-
# below does not seem necessary in our context
115-
#working-directory: "pytorch/torchcodec"
116-
shell: bash -l {0}
117-
run: |
118-
set -euxo pipefail
119-
CONDA_ENV="${RUNNER_TEMP}/pytorch_pkg_helpers_${GITHUB_RUN_ID}"
120-
conda create \
121-
--yes --quiet \
122-
--prefix "${CONDA_ENV}" \
123-
"python=3.9"
124-
CONDA_ENV="${CONDA_ENV}"
125-
CONDA_RUN="conda run -p ${CONDA_ENV}"
126-
${CONDA_RUN} python -m pip install ${GITHUB_WORKSPACE}/test-infra/tools/pkg-helpers
127-
BUILD_ENV_FILE="${RUNNER_TEMP}/build_env_${GITHUB_RUN_ID}"
128-
${CONDA_RUN} python -m pytorch_pkg_helpers > "${BUILD_ENV_FILE}"
129-
cat "${BUILD_ENV_FILE}"
130-
echo "BUILD_ENV_FILE=${BUILD_ENV_FILE}" >> "${GITHUB_ENV}"
131-
- name: Setup conda environment for build
132-
shell: bash -l {0}
133-
env:
134-
PYTHON_VERSION: ${{ matrix.python-version }}
135-
run: |
136-
set -euxo pipefail
137-
CONDA_ENV="${RUNNER_TEMP}/conda_environment_${GITHUB_RUN_ID}"
138-
if [[ "${PACKAGE_TYPE:-}" == "conda" ]]; then
139-
# For conda package host python version is irrelevant
140-
export PYTHON_VERSION=3.9
141-
export CONDA_BUILD_EXTRA="conda=24.4.0 conda-build=24.3.0 python-libarchive-c=2.9"
142-
else
143-
# For wheel builds we don't need neither conda nor conda-build
144-
export CONDA_BUILD_EXTRA=""
145-
fi
146-
147-
conda create \
148-
--yes --quiet \
149-
--prefix "${CONDA_ENV}" \
150-
"python=${PYTHON_VERSION}" \
151-
cmake=3.26 \
152-
ninja=1.10 \
153-
pkg-config=0.29 \
154-
${CONDA_BUILD_EXTRA} \
155-
wheel=0.37
156-
157-
echo "CONDA_ENV=${CONDA_ENV}" >> "${GITHUB_ENV}"
158-
echo "CONDA_RUN=conda run -p ${CONDA_ENV}" >> "${GITHUB_ENV}"
159-
## end copying
160-
- name: Run otool
161-
shell: bash -l {0}
162-
run: |
163-
echo "otool -L unzipped_wheel/torchcodec/libtorchcodec*"
164-
otool -L unzipped_wheel/torchcodec/libtorchcodec*
165-
74+
- name: Setup conda env
75+
uses: conda-incubator/setup-miniconda@v3
76+
with:
77+
auto-update-conda: true
78+
miniconda-version: "latest"
79+
activate-environment: test
80+
python-version: ${{ matrix.python-version }}
16681
- name: Update pip
16782
run: python -m pip install --upgrade pip
168-
- name: Install ffmpeg
169-
run: |
170-
${CONDA_RUN} conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
171-
${CONDA_RUN} ffmpeg -version
17283
- name: Install PyTorch
17384
run: |
174-
${CONDA_RUN} python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
85+
python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
17586
- name: Install torchcodec from the wheel
17687
run: |
17788
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
17889
echo Installing $wheel_path
179-
${CONDA_RUN} python -m pip install $wheel_path -vvv
90+
python -m pip install $wheel_path -vvv
91+
- name: Check out torchcodec repo
92+
uses: actions/checkout@v3
93+
- name: Install ffmpeg
94+
run: |
95+
conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
96+
ffmpeg -version
18097
- name: Install test dependencies
18198
run: |
182-
${CONDA_RUN} python -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
183-
${CONDA_RUN} python -m pip install numpy pytest pillow
99+
python -m pip install --pre torchvision --index-url https://download.pytorch.org/whl/nightly/cpu
100+
python -m pip install numpy pytest pillow
184101
- name: Delete the src/ folder just for fun
185102
run: |
186103
rm -r src/
187-
ls
104+
ls -lh
188105
- name: Smoke test
189106
run: |
190-
${CONDA_RUN} python -X faulthandler test/decoders/manual_smoke_test.py
191-
ls -lh
107+
python -X faulthandler test/decoders/manual_smoke_test.py
192108
- name: Run Python tests
193109
run: |
194-
${CONDA_RUN} pytest test
110+
pytest test -vvv

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,6 @@ bool VideoDecoder::canWeAvoidSeekingForStream(
657657
// AVFormatContext if it is needed. We can skip seeking in certain cases. See
658658
// the comment of canWeAvoidSeeking() for details.
659659
void VideoDecoder::maybeSeekToBeforeDesiredPts() {
660-
std::cerr << "maybeSeekToBeforeDesiredPts" << std::endl;
661660
if (activeStreamIndices_.size() == 0) {
662661
return;
663662
}
@@ -677,9 +676,6 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
677676
int64_t desiredPtsForStream = *maybeDesiredPts_ * streamInfo.timeBase.den;
678677
if (!canWeAvoidSeekingForStream(
679678
streamInfo, streamInfo.currentPts, desiredPtsForStream)) {
680-
VLOG(5) << "Seeking is needed for streamIndex=" << streamIndex
681-
<< " desiredPts=" << desiredPtsForStream
682-
<< " currentPts=" << streamInfo.currentPts;
683679
mustSeek = true;
684680
break;
685681
}
@@ -724,20 +720,14 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
724720

725721
VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
726722
std::function<bool(int, AVFrame*)> filterFunction) {
727-
std::cerr << "getDecodedOutputWithFilter" << std::endl;
728723
auto start = std::chrono::high_resolution_clock::now();
729724
if (activeStreamIndices_.size() == 0) {
730725
throw std::runtime_error("No active streams configured.");
731726
}
732-
VLOG(9) << "Starting getDecodedOutputWithFilter()";
733727
resetDecodeStats();
734728
if (maybeDesiredPts_.has_value()) {
735-
std::cerr << "\thas value" << std::endl;
736-
VLOG(9) << "maybeDesiredPts_=" << *maybeDesiredPts_;
737-
std::cerr << "\tlogged pts" << std::endl;
738729
maybeSeekToBeforeDesiredPts();
739730
maybeDesiredPts_ = std::nullopt;
740-
VLOG(9) << "seeking done";
741731
}
742732
auto seekDone = std::chrono::high_resolution_clock::now();
743733
// Need to get the next frame or error from PopFrame.
@@ -752,13 +742,9 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
752742
StreamInfo& streamInfo = streams_[streamIndex];
753743
ffmpegStatus =
754744
avcodec_receive_frame(streamInfo.codecContext.get(), frame.get());
755-
VLOG(9) << "received frame" << " status=" << ffmpegStatus
756-
<< " streamIndex=" << streamInfo.stream->index;
757745
bool gotNonRetriableError =
758746
ffmpegStatus != AVSUCCESS && ffmpegStatus != AVERROR(EAGAIN);
759747
if (gotNonRetriableError) {
760-
VLOG(9) << "Got non-retriable error from decoder: "
761-
<< getFFMPEGErrorStringFromErrorCode(ffmpegStatus);
762748
gotPermanentErrorOnAnyActiveStream = true;
763749
break;
764750
}
@@ -788,7 +774,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
788774
UniqueAVPacket packet(av_packet_alloc());
789775
ffmpegStatus = av_read_frame(formatContext_.get(), packet.get());
790776
decodeStats_.numPacketsRead++;
791-
VLOG(9) << "av_read_frame returned status: " << ffmpegStatus;
792777
if (ffmpegStatus == AVERROR_EOF) {
793778
// End of file reached. We must drain all codecs by sending a nullptr
794779
// packet.
@@ -811,8 +796,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
811796
"Could not read frame from input file: " +
812797
getFFMPEGErrorStringFromErrorCode(ffmpegStatus));
813798
}
814-
VLOG(9) << "Got packet: stream_index=" << packet->stream_index
815-
<< " pts=" << packet->pts << " size=" << packet->size;
816799
if (activeStreamIndices_.count(packet->stream_index) == 0) {
817800
// This packet is not for any of the active streams.
818801
continue;
@@ -850,10 +833,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
850833
std::chrono::duration_cast<std::chrono::milliseconds>(seekDone - start);
851834
auto seekToDecodeDone = std::chrono::duration_cast<std::chrono::milliseconds>(
852835
decodeDone - seekDone);
853-
VLOG(3) << "Got frame: stream_index=" << activeStream.stream->index
854-
<< " pts=" << frame->pts << " stats=" << decodeStats_
855-
<< " startToSeekDone=" << startToSeekDone.count() << "ms"
856-
<< " seekToDecodeDone=" << seekToDecodeDone.count() << "ms";
857836
RawDecodedOutput rawOutput;
858837
rawOutput.streamIndex = frameStreamIndex;
859838
rawOutput.frame = std::move(frame);
@@ -1021,7 +1000,6 @@ VideoDecoder::DecodedOutput VideoDecoder::getFrameAtIndex(
10211000
int streamIndex,
10221001
int64_t frameIndex,
10231002
std::optional<torch::Tensor> preAllocatedOutputTensor) {
1024-
std::cerr << "getFrameAtIndex" << std::endl;
10251003
validateUserProvidedStreamIndex(streamIndex);
10261004
validateScannedAllStreams("getFrameAtIndex");
10271005

@@ -1196,7 +1174,6 @@ VideoDecoder::getFramesDisplayedByTimestampInRange(
11961174
}
11971175

11981176
VideoDecoder::RawDecodedOutput VideoDecoder::getNextRawDecodedOutputNoDemux() {
1199-
std::cerr << "getNextRawDecodedOutputNoDemux" << std::endl;
12001177
auto rawOutput =
12011178
getDecodedOutputWithFilter([this](int frameStreamIndex, AVFrame* frame) {
12021179
StreamInfo& activeStream = streams_[frameStreamIndex];
@@ -1207,7 +1184,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getNextRawDecodedOutputNoDemux() {
12071184

12081185
VideoDecoder::DecodedOutput VideoDecoder::getNextDecodedOutputNoDemux(
12091186
std::optional<torch::Tensor> preAllocatedOutputTensor) {
1210-
std::cerr << "getNextDecodedOutputNoDemux" << std::endl;
12111187
auto rawOutput = getNextRawDecodedOutputNoDemux();
12121188
return convertAVFrameToDecodedOutput(rawOutput, preAllocatedOutputTensor);
12131189
}

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <cstdint>
1010
#include <sstream>
1111
#include <string>
12-
#include <iostream>
1312
#include "c10/core/SymIntArrayRef.h"
1413
#include "c10/util/Exception.h"
1514
#include "src/torchcodec/decoders/_core/VideoDecoder.h"
@@ -77,7 +76,6 @@ VideoDecoder* unwrapTensorToGetDecoder(at::Tensor& tensor) {
7776
}
7877

7978
OpsDecodedOutput makeOpsDecodedOutput(VideoDecoder::DecodedOutput& frame) {
80-
std::cerr << "makeOpsDecodedOutput" << std::endl;
8179
return std::make_tuple(
8280
frame.frame,
8381
torch::tensor(frame.ptsSeconds, torch::dtype(torch::kFloat64)),
@@ -215,7 +213,6 @@ OpsDecodedOutput get_frame_at_index(
215213
at::Tensor& decoder,
216214
int64_t stream_index,
217215
int64_t frame_index) {
218-
std::cerr << "get_frame_at_index" << std::endl;
219216
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
220217
auto result = videoDecoder->getFrameAtIndex(stream_index, frame_index);
221218
return makeOpsDecodedOutput(result);
@@ -283,12 +280,6 @@ bool _test_frame_pts_equality(
283280
int64_t frame_index,
284281
double pts_seconds_to_test) {
285282
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
286-
LOG(INFO) << "pts_seconds_to_test: " << std::setprecision(15)
287-
<< pts_seconds_to_test << std::endl;
288-
LOG(INFO) << "frame pts : " << std::setprecision(15)
289-
<< videoDecoder->getPtsSecondsForFrame(stream_index, frame_index)
290-
<< std::endl
291-
<< std::endl;
292283
return pts_seconds_to_test ==
293284
videoDecoder->getPtsSecondsForFrame(stream_index, frame_index);
294285
}

0 commit comments

Comments
 (0)