Skip to content

Commit 632582a

Browse files
committed
Change logging
1 parent b639a46 commit 632582a

File tree

3 files changed

+14
-121
lines changed

3 files changed

+14
-121
lines changed

.github/workflows/macos_wheel.yaml

Lines changed: 12 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,15 @@ jobs:
6868
uses: pytorch/test-infra/.github/actions/setup-miniconda@macbuildwheel
6969
with:
7070
python-version: ${{ matrix.python-version }}
71+
# - name: Update conda
72+
# run: |
73+
# # See: https://github.com/conda/conda-libmamba-solver/issues/283#issuecomment-1949560105
74+
# conda config --remove channels defaults
75+
# conda config --add channels conda-forge
76+
# conda update --all
7177
- name: Check out torchcodec repo
7278
uses: actions/checkout@v3
73-
- name: Check out tet-infra repo
79+
- name: Check out test-infra repo
7480
uses: actions/checkout@v3
7581
with:
7682
repository: pytorch/test-infra
@@ -81,101 +87,19 @@ jobs:
8187
with:
8288
name: pytorch_torchcodec__${{ matrix.python-version }}_cpu_
8389
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-
16690
- name: Update pip
16791
run: python -m pip install --upgrade pip
16892
- name: Install ffmpeg
16993
run: |
170-
${CONDA_RUN} conda install "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
94+
${CONDA_INSTALL} "ffmpeg=${{ matrix.ffmpeg-version-for-tests }}" -c conda-forge
17195
${CONDA_RUN} ffmpeg -version
17296
- name: Install PyTorch
17397
run: |
17498
${CONDA_RUN} python -m pip install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
17599
- name: Install torchcodec from the wheel
176100
run: |
177-
wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
178-
echo Installing $wheel_path
101+
${CONDA_RUN} wheel_path=`find pytorch/torchcodec/dist -type f -name "*.whl"`
102+
${CONDA_RUN} echo Installing $wheel_path
179103
${CONDA_RUN} python -m pip install $wheel_path -vvv
180104
- name: Install test dependencies
181105
run: |
@@ -184,11 +108,10 @@ jobs:
184108
- name: Delete the src/ folder just for fun
185109
run: |
186110
rm -r src/
187-
ls
111+
ls -lh
188112
- name: Smoke test
189113
run: |
190114
${CONDA_RUN} python -X faulthandler test/decoders/manual_smoke_test.py
191-
ls -lh
192115
- name: Run Python tests
193116
run: |
194-
${CONDA_RUN} pytest test
117+
${CONDA_RUN} pytest test -vvv

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <stdexcept>
1212
#include <string_view>
1313
#include "src/torchcodec/decoders/_core/DeviceInterface.h"
14+
#include "c10/util/Logging.h"
1415
#include "torch/types.h"
1516

1617
extern "C" {
@@ -657,7 +658,6 @@ bool VideoDecoder::canWeAvoidSeekingForStream(
657658
// AVFormatContext if it is needed. We can skip seeking in certain cases. See
658659
// the comment of canWeAvoidSeeking() for details.
659660
void VideoDecoder::maybeSeekToBeforeDesiredPts() {
660-
std::cerr << "maybeSeekToBeforeDesiredPts" << std::endl;
661661
if (activeStreamIndices_.size() == 0) {
662662
return;
663663
}
@@ -677,9 +677,6 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
677677
int64_t desiredPtsForStream = *maybeDesiredPts_ * streamInfo.timeBase.den;
678678
if (!canWeAvoidSeekingForStream(
679679
streamInfo, streamInfo.currentPts, desiredPtsForStream)) {
680-
VLOG(5) << "Seeking is needed for streamIndex=" << streamIndex
681-
<< " desiredPts=" << desiredPtsForStream
682-
<< " currentPts=" << streamInfo.currentPts;
683680
mustSeek = true;
684681
break;
685682
}
@@ -724,20 +721,14 @@ void VideoDecoder::maybeSeekToBeforeDesiredPts() {
724721

725722
VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
726723
std::function<bool(int, AVFrame*)> filterFunction) {
727-
std::cerr << "getDecodedOutputWithFilter" << std::endl;
728724
auto start = std::chrono::high_resolution_clock::now();
729725
if (activeStreamIndices_.size() == 0) {
730726
throw std::runtime_error("No active streams configured.");
731727
}
732-
VLOG(9) << "Starting getDecodedOutputWithFilter()";
733728
resetDecodeStats();
734729
if (maybeDesiredPts_.has_value()) {
735-
std::cerr << "\thas value" << std::endl;
736-
VLOG(9) << "maybeDesiredPts_=" << *maybeDesiredPts_;
737-
std::cerr << "\tlogged pts" << std::endl;
738730
maybeSeekToBeforeDesiredPts();
739731
maybeDesiredPts_ = std::nullopt;
740-
VLOG(9) << "seeking done";
741732
}
742733
auto seekDone = std::chrono::high_resolution_clock::now();
743734
// Need to get the next frame or error from PopFrame.
@@ -752,13 +743,9 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
752743
StreamInfo& streamInfo = streams_[streamIndex];
753744
ffmpegStatus =
754745
avcodec_receive_frame(streamInfo.codecContext.get(), frame.get());
755-
VLOG(9) << "received frame" << " status=" << ffmpegStatus
756-
<< " streamIndex=" << streamInfo.stream->index;
757746
bool gotNonRetriableError =
758747
ffmpegStatus != AVSUCCESS && ffmpegStatus != AVERROR(EAGAIN);
759748
if (gotNonRetriableError) {
760-
VLOG(9) << "Got non-retriable error from decoder: "
761-
<< getFFMPEGErrorStringFromErrorCode(ffmpegStatus);
762749
gotPermanentErrorOnAnyActiveStream = true;
763750
break;
764751
}
@@ -788,7 +775,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
788775
UniqueAVPacket packet(av_packet_alloc());
789776
ffmpegStatus = av_read_frame(formatContext_.get(), packet.get());
790777
decodeStats_.numPacketsRead++;
791-
VLOG(9) << "av_read_frame returned status: " << ffmpegStatus;
792778
if (ffmpegStatus == AVERROR_EOF) {
793779
// End of file reached. We must drain all codecs by sending a nullptr
794780
// packet.
@@ -811,8 +797,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
811797
"Could not read frame from input file: " +
812798
getFFMPEGErrorStringFromErrorCode(ffmpegStatus));
813799
}
814-
VLOG(9) << "Got packet: stream_index=" << packet->stream_index
815-
<< " pts=" << packet->pts << " size=" << packet->size;
816800
if (activeStreamIndices_.count(packet->stream_index) == 0) {
817801
// This packet is not for any of the active streams.
818802
continue;
@@ -850,10 +834,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getDecodedOutputWithFilter(
850834
std::chrono::duration_cast<std::chrono::milliseconds>(seekDone - start);
851835
auto seekToDecodeDone = std::chrono::duration_cast<std::chrono::milliseconds>(
852836
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";
857837
RawDecodedOutput rawOutput;
858838
rawOutput.streamIndex = frameStreamIndex;
859839
rawOutput.frame = std::move(frame);
@@ -1021,7 +1001,6 @@ VideoDecoder::DecodedOutput VideoDecoder::getFrameAtIndex(
10211001
int streamIndex,
10221002
int64_t frameIndex,
10231003
std::optional<torch::Tensor> preAllocatedOutputTensor) {
1024-
std::cerr << "getFrameAtIndex" << std::endl;
10251004
validateUserProvidedStreamIndex(streamIndex);
10261005
validateScannedAllStreams("getFrameAtIndex");
10271006

@@ -1196,7 +1175,6 @@ VideoDecoder::getFramesDisplayedByTimestampInRange(
11961175
}
11971176

11981177
VideoDecoder::RawDecodedOutput VideoDecoder::getNextRawDecodedOutputNoDemux() {
1199-
std::cerr << "getNextRawDecodedOutputNoDemux" << std::endl;
12001178
auto rawOutput =
12011179
getDecodedOutputWithFilter([this](int frameStreamIndex, AVFrame* frame) {
12021180
StreamInfo& activeStream = streams_[frameStreamIndex];
@@ -1207,7 +1185,6 @@ VideoDecoder::RawDecodedOutput VideoDecoder::getNextRawDecodedOutputNoDemux() {
12071185

12081186
VideoDecoder::DecodedOutput VideoDecoder::getNextDecodedOutputNoDemux(
12091187
std::optional<torch::Tensor> preAllocatedOutputTensor) {
1210-
std::cerr << "getNextDecodedOutputNoDemux" << std::endl;
12111188
auto rawOutput = getNextRawDecodedOutputNoDemux();
12121189
return convertAVFrameToDecodedOutput(rawOutput, preAllocatedOutputTensor);
12131190
}

src/torchcodec/decoders/_core/VideoDecoderOps.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <iostream>
1313
#include "c10/core/SymIntArrayRef.h"
1414
#include "c10/util/Exception.h"
15+
#include "c10/util/Logging.h"
1516
#include "src/torchcodec/decoders/_core/VideoDecoder.h"
1617

1718
namespace facebook::torchcodec {
@@ -77,7 +78,6 @@ VideoDecoder* unwrapTensorToGetDecoder(at::Tensor& tensor) {
7778
}
7879

7980
OpsDecodedOutput makeOpsDecodedOutput(VideoDecoder::DecodedOutput& frame) {
80-
std::cerr << "makeOpsDecodedOutput" << std::endl;
8181
return std::make_tuple(
8282
frame.frame,
8383
torch::tensor(frame.ptsSeconds, torch::dtype(torch::kFloat64)),
@@ -215,7 +215,6 @@ OpsDecodedOutput get_frame_at_index(
215215
at::Tensor& decoder,
216216
int64_t stream_index,
217217
int64_t frame_index) {
218-
std::cerr << "get_frame_at_index" << std::endl;
219218
auto videoDecoder = unwrapTensorToGetDecoder(decoder);
220219
auto result = videoDecoder->getFrameAtIndex(stream_index, frame_index);
221220
return makeOpsDecodedOutput(result);
@@ -283,12 +282,6 @@ bool _test_frame_pts_equality(
283282
int64_t frame_index,
284283
double pts_seconds_to_test) {
285284
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;
292285
return pts_seconds_to_test ==
293286
videoDecoder->getPtsSecondsForFrame(stream_index, frame_index);
294287
}

0 commit comments

Comments
 (0)