Lazy-load TensorFlow for TFRecord-specific pipeline paths
Los mantenedores suelen responder en 2 días
@hanzalaareeb ya está trabajando en esto.
Desde el 20/8/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- python, tensorflow
Línea de trabajo
Comience con dpsynth.data_generation y dpsynth.pipeline_transformations.input_output; después, inspeccione la ruta de importación de tfrecord_descriptor y sus ramas de I/O específicas de TFRecord. Ejecute la comprobación de importación de Python proporcionada para confirmar que los módulos que no son de TFRecord no dejan TensorFlow en sys.modules; después, ejecute las pruebas de la pipeline y verifique que las 11 pruebas existentes pasen.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 32
- Forks
- 13
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 20
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de google/dpsynth
-
import dpsynth fails because mbi.Dataset is registered as a JAX dataclass twicePosiblemente ocupada @hanzalaareeb la tomó hace 11 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
Los mantenedores suelen responder en 2 días
-
Clarify installation requirements in quickstart.ipynbPosiblemente ocupada @hanzalaareeb la tomó hace 10 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
google/dpsynth#194 · 1 comentario ·
Los mantenedores suelen responder en 2 días
-
`IndependentConfig` synthesis raises "Cliques must be unique."Quizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 2 días
-
Windows install of pylock.toml fails on the pipeline extra due to missing Windows wheel for python-dpPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
Los mantenedores suelen responder en 2 días
-
Add an option to control the maximum marginal degree in AIM workload constructionPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 65/100
google/dpsynth#199 · 3 comentarios ·
Los mantenedores suelen responder en 2 días
Todos los issues de google/dpsynth
Issues similares
-
[Bug]: `graphify export svg` writes a graph.svg that is not well-formed XML when a label contains a control characterPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Graphify-Labs/graphify#4241 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
-
DeviceTrackerAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 63/100
XiaoMi/ha_xiaomi_home#1821 ·
Los mantenedores suelen responder en 1 día
-
Maven path-index: "Ambiguous or noncanonical artifact path" error does not report the offending pathAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
pulp/pulp_maven#524 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día