Skip to main content

NeptuneOptunaTracker

NeptuneOptunaTracker(
    init_kwargs: Dict[str, Any] = _Nothing.NOTHING,
    log_kwargs: Dict[str, Any] = _Nothing.NOTHING,
    add_configs: Dict[str, Any] = _Nothing.NOTHING,
    live_stream: bool = False,
    custom_callback: systematica.utils.neptune_ai.NeptuneCallback = systematica.tuners.neptune_ai.callbacks.CustomCallback,
)
Handle Neptune-enabled optimization execution tracker. This class integrates with Neptune to track Optuna studies, allowing for both live streaming of optimization results and logging of study metadata after the study is completed.
Loading an Optuna Study from Neptune:If an Optuna study is logged to Neptune, you can reload it using the with_id flag in init_kwargs. The Neptune ID, found in the Experiments tab or sys namespace, uniquely identifies a run:
  • Active run ID: run["sys/id"].fetch()
  • Custom run ID: run["sys/custom_run_id"].fetch() Supports both InMemoryStorage and database storage.
Logging Optuna Studies to Neptune:log_kwargs controls logging via npt_utils.NeptuneCallback or log_study_metadata internally, depending on live_stream flag. By default, Neptune logs plots from optuna.visualizations, which may add overhead. Customize logging with:
  • plot_update_freq:
    • Integer k: Updates plots every k trials.
    • "never": Disables plot logging.
  • log_plot_contour, log_plot_slice, etc.: Set False to skip specific plots.
Also, to log one or more study objectives, you can pass a list of objective names to the target_names argument.
Method generated by attrs for class NeptuneOptunaTracker.

Ancestors

  • systematica.tuners.base.BaseTracker
  • abc.ABC

Class variables

  • live_stream: bool: If True, it runs the Optuna parameter live sweep with the callback. Otherwise, log study metadata after the Study is finished. The latest method is generally faster, as it doesn’t log the data live. When called, it logs the same metadata as the callback and accepts the same flags for customization. Defaults to False.
  • custom_callback: systematica.utils.neptune_ai.NeptuneCallback: Custom callback. If None, uses original NeptuneCallback. Default to CustomCallback.

Static methods

add

add(
    run: neptune.metadata_containers.run.Run,
    logs: Dict[str, Any],
)
Additional items to be stored in neptune. It only adds str, int, float and bool and ignores other data types. Parameters:
NameTypeDefaultDescription
runneptune.Run--Run.
logstp.Any--Additional items to be stored in neptune.

remove

remove(
    run: neptune.metadata_containers.run.Run,
    fields: List[str],
)
Remove fields stored in neptune. Parameters:
NameTypeDefaultDescription
runneptune.Run--Run.

count_fields

count_fields(
    structure: Dict[str, Any],
) ‑> int
Count the fields of a Neptune object, use the get_structure() method and some scripting. Note: structure is accessible through run.get_structure(). Parameters:
NameTypeDefaultDescription
structuretp.Dict[str, tp.Any]--Neptune stucture. Accessible through run.get_structure().
Returns:
TypeDescription
intNumber of fields.

Methods

run_context

run_context(
    self,
    **kwargs,
)
Context manager to initialize and stop a Neptune run. Parameters:
NameTypeDefaultDescription
kwargstp.Kwargs--Additional arguments to pass to neptune.init_run (e.g., with_id, mode).
Yields:
TypeDescription
neptune.RunThe initialized Neptune run object.

run_study

run_study(
    self,
    objective: Callable,
    create_study_kwargs: Dict[str, Any],
    optimize_kwargs: Dict[str, Any],
) ‑> optuna.study.study.Study
Run Optuna study. Parameters:
NameTypeDefaultDescription
objectivetp.Callable--Objective function.
create_study_kwargstp.Kwargs--Additional arguments for optuna.create_study.
optimize_kwargstp.Kwargs--Additional arguments for study.optimize.`
Returns:
TypeDescription
optuna.StudyThe Optuna study object containing optimization results.