safe_synthesizer.job#

Module Contents#

Classes#

ReportHtml

Class to hold the HTML report string.

SafeSynthesizerJob

Interface for convenient interaction with Safe Synthesizer jobs.

Data#

API#

class safe_synthesizer.job.ReportHtml(html: str)#

Bases: object

Class to hold the HTML report string.

Initialization

display_report_in_notebook(width='100%', height=1000) None#

Display the evaluation report in a jupyter notebook.

Requires the IPython library to be installed.

Parameters:
  • width – The width of the iframe to display the report in.

  • height – The height of the iframe to display the report in.

classmethod read(path: str | pathlib.Path) typing_extensions.Self#

Read the evaluation report from a file.

Parameters:

path – The path to read the report from.

save(path: str | pathlib.Path) None#

Save the evaluation report to a file.

Parameters:

path – The path to save the report to.

class safe_synthesizer.job.SafeSynthesizerJob(
job_name: str,
client: nemo_platform.NeMoPlatform,
workspace: str = 'default',
)#

Interface for convenient interaction with Safe Synthesizer jobs.

This class provides a wrapper around the Safe Synthesizer job SDK to make common operations easier.

An instance is returned from the create_job method of the SafeSynthesizerJobBuilder class. Or create an instance with a job id and a NeMoPlatform client.

Examples

>>> from nemo_platform import NeMoPlatform
>>> from nemo_platform.beta.safe_synthesizer.job import SafeSynthesizerJob
>>> client = NeMoPlatform(base_url=..., inference_base_url=...)
>>> job = SafeSynthesizerJob(job_id=..., client=client, workspace="default")
>>> job.fetch_status()
>>> job.wait_for_completion()
>>> job.fetch_summary()
>>> df = job.fetch_data()
>>> job.save_report("./evaluation_report.html")

And in a jupyter notebook to display the report inline:

>>> job.display_report_in_notebook()

Initialization

Initialize a SafeSynthesizerJob instance.

Parameters:
  • job_name – The name of the job to interact with (note: despite the parameter name, this should be the job name, not entity ID).

  • client – The NeMoPlatform client to use to interact with the job.

  • workspace – The workspace to use to interact with the job.

display_report_in_notebook(width='100%', height=1000) None#

Display the evaluation report in a jupyter notebook.

Requires the IPython library to be installed.

Parameters:
  • width – The width of the iframe to display the report in.

  • height – The height of the iframe to display the report in.

fetch_data() pandas.DataFrame#

Fetch the synthetic data of the job as a pandas DataFrame.

Returns:

A pandas DataFrame containing the synthetic data.

fetch_logs(
timeout: float | None = None,
) Iterator[nemo_platform.types.PlatformJobLog]#

Fetch the logs of the job as an iterator over log objects.

Recommended to use print_logs for human-readable output. This method returns an iterator over log objects and is useful for programmatic access.

Parameters:

timeout – Timeout in seconds for each log request. Defaults to 300 seconds (5 minutes) to handle jobs with many log files. Set to None to use the SDK default (60s).

Returns:

A generator for the log objects.

fetch_report() safe_synthesizer.job.ReportHtml#

Fetch the evaluation report of the job as a string of html.

Recommended to use save_report or display_report_in_notebook for most use cases.

Returns:

A string containing the html representation of the evaluation report.

fetch_status() str#

Fetch the status of the job.

Returns:

The status of the job.

fetch_status_info() nemo_platform.types.PlatformJobStatusResponse#

Fetch the status information of the job.

Returns:

The status information of the job.

fetch_summary() nemo_platform.types.safe_synthesizer.jobs.safe_synthesizer_summary.SafeSynthesizerSummary#

Fetch the summary of the job.

Returns:

A summary of machine-readable metrics for a completed job. Raises a 404 error if the job is not finished.

print_logs(timeout: float | None = None) None#

Print the logs of the job to stdout.

Parameters:

timeout – Timeout in seconds for each log request. Defaults to 300s (5 minutes).

save_report(path: str | pathlib.Path) None#

Save the evaluation report to a file.

Parameters:

path – The path to save the report to.

wait_for_completion(
poll_interval: int = 10,
verbose: bool = True,
log_timeout: float | None = None,
) None#

Block until the job is completed.

Prints the logs by default. Uses incremental log fetching via page cursor to only fetch new logs on each poll.

Parameters:
  • poll_interval – The interval in seconds to poll the job status.

  • verbose – Gets logs and prints them at this interval. Default: True

  • log_timeout – Timeout in seconds for log requests. Defaults to 300s (5 minutes).

safe_synthesizer.job.logger#

‘getLogger(…)’