Lazy-load TensorFlow for TFRecord-specific pipeline paths
I maintainer di solito rispondono entro 2 giorni
@hanzalaareeb ci sta già lavorando.
Dal 20/8/2026.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Refactoring
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python, tensorflow
- Ambito
- data-engineering, machine-learning
Direzione di ricerca
Inizia con dpsynth.data_generation e dpsynth.pipeline_transformations.input_output, quindi esamina il percorso di importazione di tfrecord_descriptor e i relativi rami di I/O specifici per TFRecord. Esegui il controllo di importazione Python fornito per confermare che i moduli non-TFRecord non lascino TensorFlow in sys.modules, quindi esegui i test della pipeline e verifica che gli 11 test esistenti passino.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
This PR removes eager TensorFlow initialization from shared pipeline import paths.
Previously, importing non-TFRecord pipeline functionality could transitively import TensorFlow:
dpsynth.data_generation
→ creating_data_recorder_converter
→ tfrecord_descriptor
→ tensorflow
As a result, workflows that do not use TFRecord, including the SWIFT pipeline test, still required TensorFlow to initialize successfully during module import.
This PR defers TFRecord-specific imports until DataFormat.TFRECORD is selected and imports TensorFlow only inside TFRecord-specific I/O paths.
Changes
- Lazily import
tfrecord_descriptorwhenDataFormat.TFRECORDis selected. - Move TensorFlow imports into TFRecord-specific branches in pipeline I/O.
- Preserve TensorFlow type annotations using the existing
from __future__ import annotationssupport andTYPE_CHECKINGimports without requiring TensorFlow at module import time. - Add regression coverage to verify that importing non-TFRecord pipeline modules does not load TensorFlow.
- Preserve existing public APIs and dependency extras.
Why
Python executes module-level imports when importing a module. The previous import structure therefore initialized TensorFlow during test collection:
pytest collection
→ import SWIFT test
→ import shared DPSynth modules
→ import TFRecord implementation
→ import TensorFlow
This happened before any SWIFT test executed.
The SWIFT workflow uses PipelineDP's LocalBackend and a dummy record converter and does not require TFRecord support. However, it could still be blocked if TensorFlow failed to initialize in the environment.
The change makes TensorFlow initialization conditional on actually entering a TFRecord code path:
shared pipeline import
→ select data format
├── non-TFRecord → TensorFlow not imported
└── TFRECORD → load TFRecord implementation → import TensorFlow
This preserves TFRecord support while preventing unrelated pipeline workflows from depending on successful TensorFlow initialization.
Verification
Confirmed that importing the shared modules no longer loads TensorFlow:
python -c "import sys; \
from dpsynth import data_generation; \
from dpsynth.pipeline_transformations import input_output; \
assert 'tensorflow' not in sys.modules"
The previously blocked pipeline tests now complete successfully:
11 passed
Some unrelated JAX, Beam, httplib2, and Pyparsing warnings remain.
- Lingua principale
- Python
- Stelle
- 32
- Fork
- 13
- Merge medio
- 1g 19h
- PR unite (30g)
- 20
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di google/dpsynth
-
import dpsynth fails because mbi.Dataset is registered as a JAX dataclass twiceForse già presa @hanzalaareeb l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Clarify installation requirements in quickstart.ipynbForse già presa @hanzalaareeb l’ha presa 10 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
google/dpsynth#194 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
`IndependentConfig` synthesis raises "Cliques must be unique."Forse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 2 giorni
-
Windows install of pylock.toml fails on the pipeline extra due to missing Windows wheel for python-dpForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
I maintainer di solito rispondono entro 2 giorni
-
Add an option to control the maximum marginal degree in AIM workload constructionForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
google/dpsynth#199 · 3 commenti ·
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di google/dpsynth
Issue simili
-
first
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AcademySoftwareFoundation/rmtc#54 · 1 commento ·
-
feature/cohorts feature/feature-flags team/feature-flags
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
License examples/ as MITForse già presa @PGrayCS l’ha presa oggi. Apertadocumentation enhancement example good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
speedyk-005/yasbd-lib#383 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
interactions-py/interactions.py#1827 ·
-
Managed start can fail when OpenVMM reads its control capability before NVX writes itForse già presa @ppenna l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno