Skip to content

Access production-ready models#

This example illustrate how to download production-stage model files.

It assumes the following:

  • You use tags to indicate model stage.
  • The model binaries are stored in the "model/binary" field of a run.

To access and download model files based on their stage:

  1. Initialize a project:

    import neptune
    
    project = neptune.init_project(
        project="workspace-name/project-name", # (1)! 
        mode="read-only",
    )   
    
    1. The full project name. For example, "ml-team/classification".

      • You can copy the name from the project details ( Details & privacy)
      • You can also find a pre-filled project string in Experiments Create a new run.
  2. Fetch the experiments table as a pandas DataFrame and filter it for runs with the "production" tag:

    runs_table_df = project.fetch_runs_table(
        tag=["production"],
        columns=[],
    ).to_pandas()
    
  3. Download the files using the download() method:

    for run_id in runs_table_df["sys/id"]:
        with neptune.init_run(with_id=run_id, mode="read-only") as run:
            run["model/binary"].download(f"{run_id}_model.pkl")
    
  4. To stop the connection to Neptune and sync all data, call the stop() method:

    project.stop()
    

Result: The model files are downloaded to the current working directory.