API Reference
This reference documents the public LitLogger surface:
- initialization functions
- module-level compatibility helpers
- the
Experimentclass - file, media, and model wrappers
- series and public enums
LightningLogger(deprecated compatibility alias)
Initialization
- litlogger.init.init(name=None, root_dir=None, teamspace=None, metadata=None, store_step=True, store_created_at=False, save_logs=False, print_url=True, verbose=True, **kwargs)
Initialize a litlogger experiment for standalone usage.
- Parameters:
name (
str|None) – Name of your experiment (defaults to a generated name).root_dir (
str|None) – Folder where logs and metadata are stored (default: ./lightning_logs).teamspace (
str|Teamspace|None) – Teamspace where charts and artifacts will appear.metadata (
dict[str,str] |None) – Extra metadata to associate with the experiment as tags.store_step (
bool|None) – Whether to store the step field with each logged value.store_created_at (
bool|None) – Whether to store a creation timestamp with each value.save_logs (
bool) – If True, capture and upload terminal logs.print_url (
bool) – Whether to print the experiment URL and initialization info.verbose (
bool) – If True, print styled console output. Defaults to True.**kwargs (
Any) – Additional keyword arguments. Will be forwarded to the Experiment constructor.
- Returns:
The initialized experiment instance.
- Return type:
Example:
import litlogger litlogger.init(name="my-experiment") for i in range(100): litlogger.log({"loss": 1.0 / (i + 1), "accuracy": i / 100.0}, step=i) litlogger.finalize()
- litlogger.init.get_metadata()
Get the metadata associated with the current experiment.
Deprecated since version Use:
experiment.metadatainstead.- Returns:
The metadata dictionary with key-value pairs from the metrics stream.
- Return type:
- Raises:
RuntimeError – If litlogger.init() has not been called.
Module-Level Helpers
These helpers are available on the top-level litlogger module after
initialization. They exist primarily for standalone compatibility workflows.
- litlogger.log(self, metrics=None, step=None, **kwargs)
Log metrics to the experiment with background uploading.
Deprecated since version Use:
experiment["key"].append(value, step=step)instead.Metrics are buffered locally and uploaded to the cloud in batches to optimize performance. The batch is sent when either 1 second has passed or 1000 values have been logged.
- Parameters:
metrics (
dict[str,float] |None) – Dictionary mapping metric names to numeric values. Example: {“loss”: 0.5, “accuracy”: 0.95}.step (
int|None) – Optional step number for this data point (e.g., training step, epoch). If None and store_step=True, no step is recorded.kwargs (
float) – Additional metric values. Can be used to provide metrics more natural. Example: loss=0.5, accuracy: 0.95.
- Raises:
RuntimeError – If the background thread encountered an error.
- Return type:
- litlogger.log_metrics(self, metrics=None, step=None, **kwargs)
Log metrics to the experiment with background uploading.
Deprecated since version Use:
experiment["key"].append(value, step=step)instead.Metrics are buffered locally and uploaded to the cloud in batches to optimize performance. The batch is sent when either 1 second has passed or 1000 values have been logged.
- Parameters:
metrics (
dict[str,float] |None) – Dictionary mapping metric names to numeric values. Example: {“loss”: 0.5, “accuracy”: 0.95}.step (
int|None) – Optional step number for this data point (e.g., training step, epoch). If None and store_step=True, no step is recorded.kwargs (
float) – Additional metric values. Can be used to provide metrics more natural. Example: loss=0.5, accuracy: 0.95.
- Raises:
RuntimeError – If the background thread encountered an error.
- Return type:
- litlogger.log_metadata(self, metadata=None, **kwargs)
Add or update metadata tags on the experiment.
Deprecated since version Use:
experiment["key"] = "value"instead.Merges the provided key-value pairs into the experiment’s existing metadata and pushes the update to the cloud immediately.
- litlogger.log_file(self, path, remote_path=None, verbose=True)
Upload a file artifact to the cloud for this experiment.
Deprecated since version Use:
experiment["key"] = File("path")orexperiment["key"].append(File("path"))instead.The file is uploaded to cloud storage and registered with the experiment, making it visible in the artifacts view and accessible via get_file().
- Parameters:
path (
str) – Path to the local file to upload. Can be absolute or relative.remote_path (
str|None) – Path relative to experiment root for storage and display. If None, uses the path relative to cwd if under cwd, otherwise basename. Example: remote_path=”images/0.png” will store and display as “images/0.png”.verbose (
bool) – Whether to print a confirmation message after upload. Defaults to True.
- Return type:
- litlogger.get_file(self, path, remote_path=None, verbose=True)
Download a file artifact from the cloud for this experiment.
Deprecated since version Use:
experiment["key"]to access files instead.The file is downloaded from cloud storage (previously uploaded via log_file) and saved to the specified local path.
- Parameters:
path (
str) – Path where the file should be saved locally. Parent directories are created if needed.remote_path (
str|None) – Path relative to experiment root where the file is stored. If None, uses the path relative to cwd if under cwd, otherwise basename. Must match the remote_path used during log_file() for correct resolution.verbose (
bool) – Whether to print a confirmation message after download. Defaults to True.
- Returns:
The local path where the file was saved (same as the input path).
- Return type:
- litlogger.log_model(self, model, staging_dir=None, verbose=False, version=None, metadata=None)
Save and upload a model object to cloud storage using litmodels.
Deprecated since version Use:
experiment["key"] = File("path")instead.This saves a live model object (e.g., PyTorch module, LightningModule) to disk using framework-specific serialization, then uploads it to the litmodels registry.
For uploading pre-saved model files, use log_model_artifact() instead.
- Parameters:
model (
Any) – The model object to save and upload (e.g., torch.nn.Module, LightningModule).staging_dir (
str|None) – Optional local directory for staging the model before upload. If None, uses a temp directory.verbose (
bool) – Whether to show progress bar during upload. Defaults to False.version (
str|None) – Optional version string for the model.metadata (
dict[str,str] |None) – Optional metadata dictionary to store with the model (e.g., hyperparameters, metrics).
- Returns:
Information about the uploaded model (details from litmodels).
- Return type:
- litlogger.get_model(self, staging_dir=None, verbose=False, version=None)
Get a model object using litmodels load_model.
Deprecated since version Use:
experiment["key"]to access models instead.
- litlogger.log_model_artifact(self, path, verbose=False, version=None)
Upload a model file or directory to cloud storage using litmodels.
Deprecated since version Use:
experiment["key"] = File("path")instead.This uploads raw model files (e.g., weights.pt, checkpoint.ckpt) or entire directories to the litmodels registry. Use this when you have pre-saved model files.
For saving model objects directly, use log_model() instead.
- litlogger.get_model_artifact(self, path, verbose=False, version=None)
Download a model artifact file or directory from cloud storage using litmodels.
Deprecated since version Use:
experiment["key"]to access model artifacts instead.This downloads raw model files or directories that were previously uploaded via log_model_artifact(). The files are saved to the specified local path.
- Parameters:
- Returns:
The local path where the model was saved (same as the input path).
- Return type:
- litlogger.finalize(self, status=None, print_summary=True)
Finalize the experiment and upload all remaining metrics.
This method waits for the background thread to finish uploading all queued metrics, and uploads terminal logs if save_logs=True. It’s automatically called on exit via an atexit handler, but can also be called manually.
This method is idempotent and can be called multiple times safely.
Experiment
- class litlogger.experiment.Experiment(name, log_dir='lightning_logs', save_logs=False, teamspace=None, light_color=None, dark_color=None, metadata=None, store_step=True, store_created_at=False, max_batch_size=1000, rate_limiting_interval=1, verbose=True)
Bases:
LegacyExperimentCore experiment with dict-like API for logging data.
- Supports pythonic dict-like access patterns:
experiment[“key”].append(value) # time series (metrics or files) experiment[“key”].extend(values) # batch time series experiment[“key”] = “value” # static metadata experiment[“key”] = File(“path”) # static file artifact experiment[“key”] # fetch data
Also inherits the legacy method-based API used for backwards compatibility (log_metrics, log_file, log_model, etc.).
Keys must be unique across metadata, artifacts, and metrics.
Initialize an experiment for logging to the https://lightning.ai platform.
- Parameters:
name (
str) – A human-friendly name for your experiment.log_dir (
str) – Local directory where temporary logs/artifacts are stored. Defaults to “lightning_logs”.save_logs (
bool) – If True, capture and upload terminal output as a file artifact. Defaults to False.teamspace (
str|Teamspace|None) – Teamspace in which to create and display the charts. If None, uses your default teamspace.light_color (
str|None) – Hex color of the curve in light mode (overrides the random default). Example: “#FF5733”.dark_color (
str|None) – Hex color of the curve in dark mode (overrides the random default). Example: “#3498DB”.metadata (
dict[str,str] |None) – Key-value parameters associated with the experiment (displayed as tags in the UI).store_step (
bool|None) – Whether to store the provided step for each data point. Defaults to True.store_created_at (
bool|None) – Whether to store a creation timestamp for each data point. Defaults to False.max_batch_size (
int) – Number of metric values to batch before uploading. Defaults to 1000.rate_limiting_interval (
int) – Minimum seconds between uploads. Defaults to 1.verbose (
bool) – If True, print styled console output. Defaults to True.
- finalize(status=None, print_summary=True)
Finalize the experiment and upload all remaining metrics.
This method waits for the background thread to finish uploading all queued metrics, and uploads terminal logs if save_logs=True. It’s automatically called on exit via an atexit handler, but can also be called manually.
This method is idempotent and can be called multiple times safely.
- get_file(path, remote_path=None, verbose=True)
Download a file artifact from the cloud for this experiment.
Deprecated since version Use:
experiment["key"]to access files instead.The file is downloaded from cloud storage (previously uploaded via log_file) and saved to the specified local path.
- Parameters:
path (
str) – Path where the file should be saved locally. Parent directories are created if needed.remote_path (
str|None) – Path relative to experiment root where the file is stored. If None, uses the path relative to cwd if under cwd, otherwise basename. Must match the remote_path used during log_file() for correct resolution.verbose (
bool) – Whether to print a confirmation message after download. Defaults to True.
- Returns:
The local path where the file was saved (same as the input path).
- Return type:
- get_model(staging_dir=None, verbose=False, version=None)
Get a model object using litmodels load_model.
Deprecated since version Use:
experiment["key"]to access models instead.
- get_model_artifact(path, verbose=False, version=None)
Download a model artifact file or directory from cloud storage using litmodels.
Deprecated since version Use:
experiment["key"]to access model artifacts instead.This downloads raw model files or directories that were previously uploaded via log_model_artifact(). The files are saved to the specified local path.
- Parameters:
- Returns:
The local path where the model was saved (same as the input path).
- Return type:
- log_file(path, remote_path=None, verbose=True)
Upload a file artifact to the cloud for this experiment.
Deprecated since version Use:
experiment["key"] = File("path")orexperiment["key"].append(File("path"))instead.The file is uploaded to cloud storage and registered with the experiment, making it visible in the artifacts view and accessible via get_file().
- Parameters:
path (
str) – Path to the local file to upload. Can be absolute or relative.remote_path (
str|None) – Path relative to experiment root for storage and display. If None, uses the path relative to cwd if under cwd, otherwise basename. Example: remote_path=”images/0.png” will store and display as “images/0.png”.verbose (
bool) – Whether to print a confirmation message after upload. Defaults to True.
- Return type:
- log_files(paths, remote_paths=None, max_workers=10)
Upload multiple file artifacts to the cloud in parallel.
Deprecated since version Use:
experiment["key"] = File("path")for each file instead.This is more efficient than calling log_file() multiple times when you have many files, as it handles them in parallel.
- Parameters:
- Return type:
- log_media(name, path, kind=None, step=None, epoch=None, caption=None, verbose=False)
Upload a media file (image, text, etc.) to the experiment.
Deprecated since version Use:
experiment["key"].append(Image(...))orexperiment["key"].append(Text(...))instead.- Parameters:
- Raises:
ValueError – If the file type cannot be determined or is not supported.
FileNotFoundError – If the file does not exist.
- Return type:
- log_metadata(metadata=None, **kwargs)
Add or update metadata tags on the experiment.
Deprecated since version Use:
experiment["key"] = "value"instead.Merges the provided key-value pairs into the experiment’s existing metadata and pushes the update to the cloud immediately.
- log_metrics(metrics=None, step=None, **kwargs)
Log metrics to the experiment with background uploading.
Deprecated since version Use:
experiment["key"].append(value, step=step)instead.Metrics are buffered locally and uploaded to the cloud in batches to optimize performance. The batch is sent when either 1 second has passed or 1000 values have been logged.
- Parameters:
metrics (
dict[str,float] |None) – Dictionary mapping metric names to numeric values. Example: {“loss”: 0.5, “accuracy”: 0.95}.step (
int|None) – Optional step number for this data point (e.g., training step, epoch). If None and store_step=True, no step is recorded.kwargs (
float) – Additional metric values. Can be used to provide metrics more natural. Example: loss=0.5, accuracy: 0.95.
- Raises:
RuntimeError – If the background thread encountered an error.
- Return type:
- log_metrics_batch(metrics)
Log a batch of metrics through the background queue.
Deprecated since version Use:
experiment["key"].extend(values, start_step=step)instead.This method converts the batch format to Metrics objects and pushes them through the background queue, which handles batching and chunking to respect API limits.
- Parameters:
metrics (
dict[str,list[dict[str,float]]]) – Dictionary mapping metric names to lists of dicts with “step” and “value” keys.- Return type:
Example:
{ "loss": [ {"step": 0, "value": 1.0}, {"step": 1, "value": 0.5}, ], "accuracy": [ {"step": 0, "value": 0.6}, {"step": 1, "value": 0.8}, ], }- Raises:
RuntimeError – If the background thread encountered an error.
- log_model(model, staging_dir=None, verbose=False, version=None, metadata=None)
Save and upload a model object to cloud storage using litmodels.
Deprecated since version Use:
experiment["key"] = File("path")instead.This saves a live model object (e.g., PyTorch module, LightningModule) to disk using framework-specific serialization, then uploads it to the litmodels registry.
For uploading pre-saved model files, use log_model_artifact() instead.
- Parameters:
model (
Any) – The model object to save and upload (e.g., torch.nn.Module, LightningModule).staging_dir (
str|None) – Optional local directory for staging the model before upload. If None, uses a temp directory.verbose (
bool) – Whether to show progress bar during upload. Defaults to False.version (
str|None) – Optional version string for the model.metadata (
dict[str,str] |None) – Optional metadata dictionary to store with the model (e.g., hyperparameters, metrics).
- Returns:
Information about the uploaded model (details from litmodels).
- Return type:
- log_model_artifact(path, verbose=False, version=None)
Upload a model file or directory to cloud storage using litmodels.
Deprecated since version Use:
experiment["key"] = File("path")instead.This uploads raw model files (e.g., weights.pt, checkpoint.ckpt) or entire directories to the litmodels registry. Use this when you have pre-saved model files.
For saving model objects directly, use log_model() instead.
- print_url()
Print the experiment URL and initialization info with styled output.
- Return type:
- update(data)
Bulk-update the experiment with multiple keys at once.
- Dispatches each value based on its type:
str → metadata (same as experiment[“key”] = “value”) File → static file artifact (same as experiment[“key”] = file) float/int → append a single metric point (same as experiment[“key”].append(value)) list → extend a time series (same as experiment[“key”].extend(values))
- property artifacts
Get all artifacts (static files and file series) logged to this experiment.
- property metadata
Get the metadata associated with this experiment from the metrics stream.
- property metrics
Get all metric time series logged to this experiment.
- property teamspace
Get the teamspace for this experiment.
- Returns:
The teamspace object.
- Return type:
Teamspace
- property url
Get the direct URL to view this experiment in the Lightning.ai web interface.
- Returns:
The full URL to the experiment’s visualization page.
- Return type:
Media Wrappers
- class litlogger.media.File(path, description='')
Bases:
objectRepresents a file to be logged to the experiment.
- Parameters:
- save(path)
Download the remote file to a local path.
Only works for files that have been uploaded to an experiment.
- Parameters:
path (
str) – Local path where the file should be saved.- Returns:
The local path where the file was saved.
- Return type:
- Raises:
RuntimeError – If the file has no remote download context.
- class litlogger.media.Image(data, format='png', description='')
Bases:
FileRepresents an image to be logged.
Can take a file path (str) or a Python object (PIL Image, numpy array, or torch Tensor) and will render it to a temporary file for upload.
- class litlogger.media.Video(data, format='mp4', description='', fps=None)
Bases:
File- DEFAULT_FPS = 24
Represents a video to be logged.
Accepts: - a file path string - a MoviePy clip - a numpy array / torch tensor of frames
Supported array shapes: - (T, H, W) grayscale frames - (T, H, W, C) frames in HWC format - (T, C, H, W) frames in CHW format, where C is 1/3/4
- Parameters:
data – Video data or a path to a video file.
format – Output container/extension, default “mp4”.
description – Optional description.
fps – Frames per second used when rendering arrays or clips that do not already carry fps metadata.
- class litlogger.media.Model(data, name=None, version=None, metadata=None, staging_dir=None, description='', _kind=None)
Bases:
FileRepresents a model to be logged.
Can take either a Python model object or a local path to a pre-saved model artifact. Uploads are handled through the model registry.
- Parameters:
data (
Any) – Python model object or path to a pre-saved model file/directory.name (
str|None) – Optional registry name override for this model. Defaults to the experiment name.version (
str|None) – Optional model version. Defaults to"latest".metadata (
dict[str,str] |None) – Optional metadata to associate with the model upload.staging_dir (
str|None) – Optional local staging directory for object-based uploads.description (
str) – Optional human-readable description of the model.
- classmethod from_remote(model_name, kind, version=None)
Create a remote-bound model wrapper for resumed experiments.
- Return type:
- load(staging_dir=None)
Load a remote model object via the registry helpers.
- Return type:
Series
- class litlogger.series.Series(experiment, key)
Bases:
objectA list-like proxy for time-series data that supports append and extend.
Tracks either metric values (floats) or file series (File objects). The type is determined by the first value appended and cannot be mixed.
- append(value, step=None)
Append a value to the time series.
Types
- class litlogger.types.MetricValue(value, step=None, created_at=None)
Bases:
objectA single metric value with optional step and timestamp.
- value
The numeric metric value.
- step
Optional step number for this value.
- created_at
Optional datetime when this value was created.
- class litlogger.types.Metrics(name, values=<factory>)
Bases:
objectA collection of metric values for a named metric.
- name
The metric name (e.g., “loss”, “accuracy”).
- values
List of metric values.
Model Registry Helpers
These helpers are available from litlogger.models and expose the
vendored model-registry API on the LitLogger side.
- litlogger.models.upload_model(name, model, progress_bar=True, cloud_account=None, verbose=1, metadata=None, experiment=None)
Upload a local artifact (file or directory) to Lightning Cloud Models.
- Return type:
UploadedModelInfo
- litlogger.models.save_model(name, model, progress_bar=True, cloud_account=None, staging_dir=None, verbose=1, metadata=None, experiment=None)
Serialize an in-memory model and upload it to Lightning Cloud Models.
- Return type:
UploadedModelInfo
- litlogger.models.load_model(name, download_dir='.')
Download a model and load it into memory based on its file extension.
- Return type:
- litlogger.models.upload_model_files(name, path, progress_bar=True, cloud_account=None, verbose=1, metadata=None, experiment=None)
Upload local artifact(s) to Lightning Cloud using the SDK.
- Return type:
UploadedModelInfo
LightningLogger
Deprecated compatibility alias for Lightning/Fabric integration. Prefer
lightning:lightning.pytorch.loggers.LitLogger, or use
litlogger.init.init and the dict-style
Experiment API for standalone usage.
- class litlogger.logger.LightningLogger(*args, **kwargs)
Bases:
LitLogger,LitLoggerDeprecated compatibility alias for the upstream Lightning LitLogger.
Deprecated since version 2026.03.17: Use
lightning.pytorch.loggers.LitLoggerfor Lightning/Fabric integration, or uselitlogger.init.init()and the dict-styleExperimentAPI for standalone scripts.
Was this page helpful?
Thanks for the feedback.