Skip to content

Commit

Permalink
copybara strip some externally unsupported features of the metric writer
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 688554082
  • Loading branch information
Qwlouse authored and The kauldron Authors committed Oct 22, 2024
1 parent 0121f78 commit ebb9144
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 247 deletions.
12 changes: 5 additions & 7 deletions examples/mnist_autoencoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@

r"""Minimal example training a simple Autoencoder on MNIST.
`--xp.use_interpreter` to launch with `ml_python` (no BUILD rules).
Run:
```sh
xmanager launch third_party/py/kauldron/xm/launch.py -- \
--cfg=third_party/py/kauldron/examples/mnist_autoencoder.py \
--xp.use_interpreter \
--xp.platform=jf=2x2
python main.py --cfg=examples/mnist_autoencoder.py \
--cfg.workdir=/tmp/kauldron_oss/workdir
```
"""
Expand Down Expand Up @@ -90,7 +87,8 @@ def get_config():


def _make_ds(training: bool):
return kd.data.Tfds(
Tfds = kd.data.py.Tfds
return Tfds(
name="mnist",
split="train" if training else "test",
shuffle=True if training else False,
Expand Down
71 changes: 0 additions & 71 deletions examples/test/minimal.py

This file was deleted.

107 changes: 0 additions & 107 deletions examples/test/mnist_autoencoder.py

This file was deleted.

27 changes: 0 additions & 27 deletions examples/test/mock_data.py

This file was deleted.

39 changes: 5 additions & 34 deletions kauldron/train/metric_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,15 +358,9 @@ class KDMetricWriter(MetadataWriter):

add_artifacts: bool = True

flatboard_build_context: kdash.BuildContext = (
config_util.ROOT_CFG_REF.setup.flatboard_build_context
)

@functools.cached_property
def _collection_path_prefix(self) -> str:
if self.flatboard_build_context.collection_path_prefix is None:
raise ValueError("collection_path_prefix must be set.")
return self.flatboard_build_context.collection_path_prefix
return ""

@functools.cached_property
def _scalar_datatable_name(self) -> str:
Expand Down Expand Up @@ -416,27 +410,7 @@ def _array_writer(self) -> metric_writers.MetricWriter:
def _create_datatable_writer(
self, name: str, description: str
) -> metric_writers.MetricWriter:
if epy.is_test():
return self._noop # Do not write to datatable inside tests
if status.on_xmanager:
if not status.is_lead_host:
return self._noop
if status.wid == 1 and self.add_artifacts:
status.xp.create_artifact(
artifact_type=xmanager_api.ArtifactType.ARTIFACT_TYPE_STORAGE2_BIGTABLE,
artifact=name,
description=description,
)
keys = [("wid", status.wid)]
else:
keys = []

return metric_writers.AsyncWriter(
metric_writers.DatatableWriter(
datatable_name=name,
keys=keys,
),
)
return self._noop

def write_summaries(
self,
Expand Down Expand Up @@ -504,12 +478,9 @@ def write_pointcloud(
point_colors: Mapping[str, Array["n 3"]] | None = None,
configs: Mapping[str, str | float | bool | None] | None = None,
) -> None:
self._tf_summary_writer.write_pointcloud(
step=step,
point_clouds=point_clouds,
point_colors=point_colors,
configs=configs,
)
if not point_clouds:
return
logging.info("Pointcloud summary not supported.")

def write_hparams(self, hparams: Mapping[str, Any]) -> None:
self._log_writer.write_hparams(hparams)
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ dependencies = [
"regex",
"scikit-image",
"scikit-learn",
"tabulate", # used by pandas.DataFrame.to_markdown (for logging context)
"tensorflow",
"tensorflow_datasets",
"tfds-nightly", # TODO(klausg): switch back to tensorflow_datasets>=4.9.7
# once released: https://github.com/tensorflow/datasets/commit/d4bfd59863c6cb5b64d043b7cb6ab566e7d92440
"tqdm",
# closest match to the internal typeguard
"typeguard@git+https://github.com/agronholm/typeguard@0dd7f7510b7c694e66a0d17d1d58d185125bad5d",
Expand Down

0 comments on commit ebb9144

Please sign in to comment.