יצירה וניהול של הרצות ניסויים

אפשר להשתמש ב-Agent Platform SDK for Python כדי ליצור ולנהל את ההרצות של הניסויים. אפשר להשתמש במסוף Google Cloud כדי למחוק הרצות של ניסויים.

Agent Platform SDK ל-Python

בדוגמאות הבאות נעשה שימוש ב-methods‏ init,‏ start_run ו-end_run מהפונקציות של aiplatform Package, וב-method‏ delete מ-ExperimentClass.

יצירה והתחלת הרצה

Python

from typing import Optional, Union

from google.cloud import aiplatform


def create_experiment_run_sample(
    experiment_name: str,
    run_name: str,
    experiment_run_tensorboard: Optional[Union[str, aiplatform.Tensorboard]],
    project: str,
    location: str,
):
    aiplatform.init(experiment=experiment_name, project=project, location=location)

    aiplatform.start_run(run=run_name, tensorboard=experiment_run_tensorboard)

  • experiment_name: מציינים את שם הניסוי. רשימת הניסויים מופיעה במסוף Google Cloud אחרי שבוחרים באפשרות 'ניסויים' בקטע הניווט.
  • run_name: מציינים שם להרצה כדי לשייך אותו לסשן הנוכחי. מידע נוסף זמין במאמר start_run במאמרי העזרה של Agent Platform SDK.
  • experiment_run_tensorboard: אופציונלי. משאב TensorBoard בסיסי שמאפשר לאחסן מדדים של סדרות זמן שנרשמו בריצת הניסוי הזו באמצעות log_time_series_metrics.
  • project: . אפשר למצוא את המזהים האלה בדף welcome במסוף Google Cloud .
  • location: ראו רשימה של מיקומים זמינים

סיום ההרצה

Python

from google.cloud import aiplatform


def end_experiment_run_sample(
    experiment_name: str,
    run_name: str,
    project: str,
    location: str,
):
    aiplatform.init(experiment=experiment_name, project=project, location=location)

    aiplatform.start_run(run=run_name, resume=True)

    aiplatform.end_run()

  • experiment_name: מציינים את שם הניסוי. רשימת הניסויים מופיעה במסוף Google Cloud אחרי שבוחרים באפשרות 'ניסויים' בקטע הניווט.
  • run_name: מציינים שם להרצה.
  • project: . אפשר למצוא אותם בדף welcome במסוף Google Cloud .
  • location: אפשר לעיין ברשימת המיקומים הזמינים

המשך ההפעלה

Python

from google.cloud import aiplatform


def resume_experiment_run_sample(
    experiment_name: str,
    run_name: str,
    project: str,
    location: str,
):
    aiplatform.init(experiment=experiment_name, project=project, location=location)

    aiplatform.start_run(run=run_name, resume=True)

  • experiment_name: מציינים את שם הניסוי. רשימת הניסויים מופיעה במסוף Google Cloud אחרי שבוחרים באפשרות 'ניסויים' בקטע הניווט.
  • run_name: מציינים את שם ההרצה שרוצים להמשיך.
  • project: . אפשר למצוא אותם בדף welcome במסוף Google Cloud .
  • location: אפשר לעיין ברשימת המיקומים הזמינים

מחיקת הרצה

Python

from typing import Union

from google.cloud import aiplatform


def delete_experiment_run_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
    delete_backing_tensorboard_run: bool = False,
):
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name, experiment=experiment, project=project, location=location
    )

    experiment_run.delete(delete_backing_tensorboard_run=delete_backing_tensorboard_run)

  • experiment: השם או המופע של הניסוי. רשימת הניסויים מופיעה במסוף Google Cloud אחרי שבוחרים באפשרות 'ניסויים' בסרגל הניווט של הקטע.
  • run_name: מציינים את שם ההרצה שרוצים למחוק.
  • project: . אפשר למצוא אותם בדף welcome במסוף Google Cloud .
  • location: אפשר לעיין ברשימת המיקומים הזמינים
  • delete_backing_tensorboard_run: האם למחוק את הריצה של Vertex AI TensorBoard שמאחורי הקלעים, שבה מאוחסנים מדדים של סדרות זמן עבור הריצה הזו.

ניהול הסטטוס

Python

from typing import Union

from google.cloud import aiplatform


def update_experiment_run_state_sample(
    run_name: str,
    experiment: Union[str, aiplatform.Experiment],
    project: str,
    location: str,
    state: aiplatform.gapic.Execution.State,
) -> None:
    experiment_run = aiplatform.ExperimentRun(
        run_name=run_name,
        experiment=experiment,
        project=project,
        location=location,
    )

    experiment_run.update_state(state)

  • run_name: שם ההרצה שמשויך לניסוי
  • experiment_name: שם הניסוי. כדי לראות את רשימת הניסויים, בוחרים באפשרות Experiments בסרגל הניווט של הקטע במסוף Google Cloud .
  • project: . אפשר למצוא את מזהי הפרויקטים האלה בדף welcome במסוף Google Cloud .
  • location: ראו רשימה של מיקומים זמינים
  • state: הערכים האפשריים של state, שמופיע כ'סטטוס' במסוף Google Cloud , הם:
    • aiplatform.gapic.Execution.State.CACHED
    • aiplatform.gapic.Execution.State.CANCELLED
    • aiplatform.gapic.Execution.State.COMPLETE
    • aiplatform.gapic.Execution.State.FAILED
    • aiplatform.gapic.Execution.State.NEW
    • aiplatform.gapic.Execution.State.RUNNING

מסוף Google Cloud

כדי למחוק הרצת ניסוי, פועלים לפי השלבים הבאים.
  1. נכנסים לדף Experiments במסוף Google Cloud .
    כניסה לדף 'ניסויים'
  2. בדף פרטי הניסוי, לוחצים על השם של הניסוי שמשויך להרצת הניסוי שרוצים למחוק. יופיע הדף הפעלות של ניסויים עם רשימה של כל הפעלות הניסוי עבור הניסוי הזה.
  3. מסמנים את תיבת הסימון שמשויכת להרצה שרוצים למחוק. יופיע הלחצן מחיקה.
  4. לוחצים על מחיקה.
    • אפשר גם לעבור לתפריט  האפשרויות שנמצא באותה שורה של הניסוי, ולבחור באפשרות מחיקה.

הצגת רשימה של הרצות ניסוי ופרטי הרצה

Google Cloud במסוף מוצגת הדמיה של הנתונים שמשויכים להרצות האלה.

המאמרים הבאים