@@ -1805,6 +1805,7 @@ def run( |
1805 | 1805 | service_account: Optional[str] = None, |
1806 | 1806 | bigquery_destination: Optional[str] = None, |
1807 | 1807 | args: Optional[List[Union[str, float, int]]] = None, |
| 1808 | + environment_variables: Optional[Dict[str, str]] = None, |
1808 | 1809 | replica_count: int = 0, |
1809 | 1810 | machine_type: str = "n1-standard-4", |
1810 | 1811 | accelerator_type: str = "ACCELERATOR_TYPE_UNSPECIFIED", |
@@ -1880,6 +1881,13 @@ def run( |
1880 | 1881 | base_output_dir (str): |
1881 | 1882 | GCS output directory of job. If not provided a |
1882 | 1883 | timestamped directory in the staging directory will be used. |
| 1884 | +
|
| 1885 | + AI Platform sets the following environment variables when it runs your training code: |
| 1886 | +
|
| 1887 | + - AIP_MODEL_DIR: a Cloud Storage URI of a directory intended for saving model artifacts, i.e. <base_output_dir>/model/ |
| 1888 | + - AIP_CHECKPOINT_DIR: a Cloud Storage URI of a directory intended for saving checkpoints, i.e. <base_output_dir>/checkpoints/ |
| 1889 | + - AIP_TENSORBOARD_LOG_DIR: a Cloud Storage URI of a directory intended for saving TensorBoard logs, i.e. <base_output_dir>/logs/ |
| 1890 | +
|
1883 | 1891 | service_account (str): |
1884 | 1892 | Specifies the service account for workload run-as account. |
1885 | 1893 | Users submitting jobs must have act-as permission on this run-as account. |
@@ -1900,6 +1908,16 @@ def run( |
1900 | 1908 | - AIP_TEST_DATA_URI = "bigquery_destination.dataset_*.test" |
1901 | 1909 | args (List[Unions[str, int, float]]): |
1902 | 1910 | Command line arguments to be passed to the Python script. |
| 1911 | + environment_variables (Dict[str, str]): |
| 1912 | + Environment variables to be passed to the container. |
| 1913 | + Should be a dictionary where keys are environment variable names |
| 1914 | + and values are environment variable values for those names. |
| 1915 | + At most 10 environment variables can be specified. |
| 1916 | + The Name of the environment variable must be unique. |
| 1917 | +
|
| 1918 | + environment_variables = { |
| 1919 | + 'MY_KEY': 'MY_VALUE' |
| 1920 | + } |
1903 | 1921 | replica_count (int): |
1904 | 1922 | The number of worker replicas. If replica count = 1 then one chief |
1905 | 1923 | replica will be provisioned. If replica_count > 1 the remainder will be |
@@ -1960,6 +1978,7 @@ def run( |
1960 | 1978 | worker_pool_specs=worker_pool_specs, |
1961 | 1979 | managed_model=managed_model, |
1962 | 1980 | args=args, |
| 1981 | + environment_variables=environment_variables, |
1963 | 1982 | base_output_dir=base_output_dir, |
1964 | 1983 | service_account=service_account, |
1965 | 1984 | bigquery_destination=bigquery_destination, |
@@ -1986,6 +2005,7 @@ def _run( |
1986 | 2005 | worker_pool_specs: _DistributedTrainingSpec, |
1987 | 2006 | managed_model: Optional[gca_model.Model] = None, |
1988 | 2007 | args: Optional[List[Union[str, float, int]]] = None, |
| 2008 | + environment_variables: Optional[Dict[str, str]] = None, |
1989 | 2009 | base_output_dir: Optional[str] = None, |
1990 | 2010 | service_account: Optional[str] = None, |
1991 | 2011 | bigquery_destination: Optional[str] = None, |
@@ -2018,9 +2038,26 @@ def _run( |
2018 | 2038 | Model proto if this script produces a Managed Model. |
2019 | 2039 | args (List[Unions[str, int, float]]): |
2020 | 2040 | Command line arguments to be passed to the Python script. |
| 2041 | + environment_variables (Dict[str, str]): |
| 2042 | + Environment variables to be passed to the container. |
| 2043 | + Should be a dictionary where keys are environment variable names |
| 2044 | + and values are environment variable values for those names. |
| 2045 | + At most 10 environment variables can be specified. |
| 2046 | + The Name of the environment variable must be unique. |
| 2047 | +
|
| 2048 | + environment_variables = { |
| 2049 | + 'MY_KEY': 'MY_VALUE' |
| 2050 | + } |
2021 | 2051 | base_output_dir (str): |
2022 | 2052 | GCS output directory of job. If not provided a |
2023 | 2053 | timestamped directory in the staging directory will be used. |
| 2054 | +
|
| 2055 | + AI Platform sets the following environment variables when it runs your training code: |
| 2056 | +
|
| 2057 | + - AIP_MODEL_DIR: a Cloud Storage URI of a directory intended for saving model artifacts, i.e. <base_output_dir>/model/ |
| 2058 | + - AIP_CHECKPOINT_DIR: a Cloud Storage URI of a directory intended for saving checkpoints, i.e. <base_output_dir>/checkpoints/ |
| 2059 | + - AIP_TENSORBOARD_LOG_DIR: a Cloud Storage URI of a directory intended for saving TensorBoard logs, i.e. <base_output_dir>/logs/ |
| 2060 | +
|
2024 | 2061 | service_account (str): |
2025 | 2062 | Specifies the service account for workload run-as account. |
2026 | 2063 | Users submitting jobs must have act-as permission on this run-as account. |
@@ -2083,6 +2120,13 @@ def _run( |
2083 | 2120 | if args: |
2084 | 2121 | spec["pythonPackageSpec"]["args"] = args |
2085 | 2122 |
|
| 2123 | + if environment_variables: |
| 2124 | + env = [ |
| 2125 | + gca_env_var.EnvVar(name=str(key), value=str(value)) |
| 2126 | + for key, value in environment_variables.items() |
| 2127 | + ] |
| 2128 | + spec["pythonPackageSpec"]["env"] = env |
| 2129 | + |
2086 | 2130 | ( |
2087 | 2131 | training_task_inputs, |
2088 | 2132 | base_output_dir, |
@@ -2334,6 +2378,7 @@ def run( |
2334 | 2378 | service_account: Optional[str] = None, |
2335 | 2379 | bigquery_destination: Optional[str] = None, |
2336 | 2380 | args: Optional[List[Union[str, float, int]]] = None, |
| 2381 | + environment_variables: Optional[Dict[str, str]] = None, |
2337 | 2382 | replica_count: int = 0, |
2338 | 2383 | machine_type: str = "n1-standard-4", |
2339 | 2384 | accelerator_type: str = "ACCELERATOR_TYPE_UNSPECIFIED", |
@@ -2402,6 +2447,13 @@ def run( |
2402 | 2447 | base_output_dir (str): |
2403 | 2448 | GCS output directory of job. If not provided a |
2404 | 2449 | timestamped directory in the staging directory will be used. |
| 2450 | +
|
| 2451 | + AI Platform sets the following environment variables when it runs your training code: |
| 2452 | +
|
| 2453 | + - AIP_MODEL_DIR: a Cloud Storage URI of a directory intended for saving model artifacts, i.e. <base_output_dir>/model/ |
| 2454 | + - AIP_CHECKPOINT_DIR: a Cloud Storage URI of a directory intended for saving checkpoints, i.e. <base_output_dir>/checkpoints/ |
| 2455 | + - AIP_TENSORBOARD_LOG_DIR: a Cloud Storage URI of a directory intended for saving TensorBoard logs, i.e. <base_output_dir>/logs/ |
| 2456 | +
|
2405 | 2457 | service_account (str): |
2406 | 2458 | Specifies the service account for workload run-as account. |
2407 | 2459 | Users submitting jobs must have act-as permission on this run-as account. |
@@ -2422,6 +2474,16 @@ def run( |
2422 | 2474 | - AIP_TEST_DATA_URI = "bigquery_destination.dataset_*.test" |
2423 | 2475 | args (List[Unions[str, int, float]]): |
2424 | 2476 | Command line arguments to be passed to the Python script. |
| 2477 | + environment_variables (Dict[str, str]): |
| 2478 | + Environment variables to be passed to the container. |
| 2479 | + Should be a dictionary where keys are environment variable names |
| 2480 | + and values are environment variable values for those names. |
| 2481 | + At most 10 environment variables can be specified. |
| 2482 | + The Name of the environment variable must be unique. |
| 2483 | +
|
| 2484 | + environment_variables = { |
| 2485 | + 'MY_KEY': 'MY_VALUE' |
| 2486 | + } |
2425 | 2487 | replica_count (int): |
2426 | 2488 | The number of worker replicas. If replica count = 1 then one chief |
2427 | 2489 | replica will be provisioned. If replica_count > 1 the remainder will be |
@@ -2481,6 +2543,7 @@ def run( |
2481 | 2543 | worker_pool_specs=worker_pool_specs, |
2482 | 2544 | managed_model=managed_model, |
2483 | 2545 | args=args, |
| 2546 | + environment_variables=environment_variables, |
2484 | 2547 | base_output_dir=base_output_dir, |
2485 | 2548 | service_account=service_account, |
2486 | 2549 | bigquery_destination=bigquery_destination, |
@@ -2506,6 +2569,7 @@ def _run( |
2506 | 2569 | worker_pool_specs: _DistributedTrainingSpec, |
2507 | 2570 | managed_model: Optional[gca_model.Model] = None, |
2508 | 2571 | args: Optional[List[Union[str, float, int]]] = None, |
| 2572 | + environment_variables: Optional[Dict[str, str]] = None, |
2509 | 2573 | base_output_dir: Optional[str] = None, |
2510 | 2574 | service_account: Optional[str] = None, |
2511 | 2575 | bigquery_destination: Optional[str] = None, |
@@ -2535,9 +2599,26 @@ def _run( |
2535 | 2599 | Model proto if this script produces a Managed Model. |
2536 | 2600 | args (List[Unions[str, int, float]]): |
2537 | 2601 | Command line arguments to be passed to the Python script. |
| 2602 | + environment_variables (Dict[str, str]): |
| 2603 | + Environment variables to be passed to the container. |
| 2604 | + Should be a dictionary where keys are environment variable names |
| 2605 | + and values are environment variable values for those names. |
| 2606 | + At most 10 environment variables can be specified. |
| 2607 | + The Name of the environment variable must be unique. |
| 2608 | +
|
| 2609 | + environment_variables = { |
| 2610 | + 'MY_KEY': 'MY_VALUE' |
| 2611 | + } |
2538 | 2612 | base_output_dir (str): |
2539 | 2613 | GCS output directory of job. If not provided a |
2540 | 2614 | timestamped directory in the staging directory will be used. |
| 2615 | +
|
| 2616 | + AI Platform sets the following environment variables when it runs your training code: |
| 2617 | +
|
| 2618 | + - AIP_MODEL_DIR: a Cloud Storage URI of a directory intended for saving model artifacts, i.e. <base_output_dir>/model/ |
| 2619 | + - AIP_CHECKPOINT_DIR: a Cloud Storage URI of a directory intended for saving checkpoints, i.e. <base_output_dir>/checkpoints/ |
| 2620 | + - AIP_TENSORBOARD_LOG_DIR: a Cloud Storage URI of a directory intended for saving TensorBoard logs, i.e. <base_output_dir>/logs/ |
| 2621 | +
|
2541 | 2622 | service_account (str): |
2542 | 2623 | Specifies the service account for workload run-as account. |
2543 | 2624 | Users submitting jobs must have act-as permission on this run-as account. |
@@ -2593,6 +2674,13 @@ def _run( |
2593 | 2674 | if args: |
2594 | 2675 | spec["containerSpec"]["args"] = args |
2595 | 2676 |
|
| 2677 | + if environment_variables: |
| 2678 | + env = [ |
| 2679 | + gca_env_var.EnvVar(name=str(key), value=str(value)) |
| 2680 | + for key, value in environment_variables.items() |
| 2681 | + ] |
| 2682 | + spec["containerSpec"]["env"] = env |
| 2683 | + |
2596 | 2684 | ( |
2597 | 2685 | training_task_inputs, |
2598 | 2686 | base_output_dir, |
@@ -3625,6 +3713,7 @@ def run( |
3625 | 3713 | service_account: Optional[str] = None, |
3626 | 3714 | bigquery_destination: Optional[str] = None, |
3627 | 3715 | args: Optional[List[Union[str, float, int]]] = None, |
| 3716 | + environment_variables: Optional[Dict[str, str]] = None, |
3628 | 3717 | replica_count: int = 0, |
3629 | 3718 | machine_type: str = "n1-standard-4", |
3630 | 3719 | accelerator_type: str = "ACCELERATOR_TYPE_UNSPECIFIED", |
@@ -3693,6 +3782,13 @@ def run( |
3693 | 3782 | base_output_dir (str): |
3694 | 3783 | GCS output directory of job. If not provided a |
3695 | 3784 | timestamped directory in the staging directory will be used. |
| 3785 | +
|
| 3786 | + AI Platform sets the following environment variables when it runs your training code: |
| 3787 | +
|
| 3788 | + - AIP_MODEL_DIR: a Cloud Storage URI of a directory intended for saving model artifacts, i.e. <base_output_dir>/model/ |
| 3789 | + - AIP_CHECKPOINT_DIR: a Cloud Storage URI of a directory intended for saving checkpoints, i.e. <base_output_dir>/checkpoints/ |
| 3790 | + - AIP_TENSORBOARD_LOG_DIR: a Cloud Storage URI of a directory intended for saving TensorBoard logs, i.e. <base_output_dir>/logs/ |
| 3791 | +
|
3696 | 3792 | service_account (str): |
3697 | 3793 | Specifies the service account for workload run-as account. |
3698 | 3794 | Users submitting jobs must have act-as permission on this run-as account. |
@@ -3713,6 +3809,16 @@ def run( |
3713 | 3809 | - AIP_TEST_DATA_URI = "bigquery_destination.dataset_*.test" |
3714 | 3810 | args (List[Unions[str, int, float]]): |
3715 | 3811 | Command line arguments to be passed to the Python script. |
| 3812 | + environment_variables (Dict[str, str]): |
| 3813 | + Environment variables to be passed to the container. |
| 3814 | + Should be a dictionary where keys are environment variable names |
| 3815 | + and values are environment variable values for those names. |
| 3816 | + At most 10 environment variables can be specified. |
| 3817 | + The Name of the environment variable must be unique. |
| 3818 | +
|
| 3819 | + environment_variables = { |
| 3820 | + 'MY_KEY': 'MY_VALUE' |
| 3821 | + } |
3716 | 3822 | replica_count (int): |
3717 | 3823 | The number of worker replicas. If replica count = 1 then one chief |
3718 | 3824 | replica will be provisioned. If replica_count > 1 the remainder will be |
@@ -3767,6 +3873,7 @@ def run( |
3767 | 3873 | worker_pool_specs=worker_pool_specs, |
3768 | 3874 | managed_model=managed_model, |
3769 | 3875 | args=args, |
| 3876 | + environment_variables=environment_variables, |
3770 | 3877 | base_output_dir=base_output_dir, |
3771 | 3878 | service_account=service_account, |
3772 | 3879 | training_fraction_split=training_fraction_split, |
@@ -3792,6 +3899,7 @@ def _run( |
3792 | 3899 | worker_pool_specs: _DistributedTrainingSpec, |
3793 | 3900 | managed_model: Optional[gca_model.Model] = None, |
3794 | 3901 | args: Optional[List[Union[str, float, int]]] = None, |
| 3902 | + environment_variables: Optional[Dict[str, str]] = None, |
3795 | 3903 | base_output_dir: Optional[str] = None, |
3796 | 3904 | service_account: Optional[str] = None, |
3797 | 3905 | training_fraction_split: float = 0.8, |
@@ -3822,9 +3930,26 @@ def _run( |
3822 | 3930 | Model proto if this script produces a Managed Model. |
3823 | 3931 | args (List[Unions[str, int, float]]): |
3824 | 3932 | Command line arguments to be passed to the Python script. |
| 3933 | + environment_variables (Dict[str, str]): |
| 3934 | + Environment variables to be passed to the container. |
| 3935 | + Should be a dictionary where keys are environment variable names |
| 3936 | + and values are environment variable values for those names. |
| 3937 | + At most 10 environment variables can be specified. |
| 3938 | + The Name of the environment variable must be unique. |
| 3939 | +
|
| 3940 | + environment_variables = { |
| 3941 | + 'MY_KEY': 'MY_VALUE' |
| 3942 | + } |
3825 | 3943 | base_output_dir (str): |
3826 | 3944 | GCS output directory of job. If not provided a |
3827 | 3945 | timestamped directory in the staging directory will be used. |
| 3946 | +
|
| 3947 | + AI Platform sets the following environment variables when it runs your training code: |
| 3948 | +
|
| 3949 | + - AIP_MODEL_DIR: a Cloud Storage URI of a directory intended for saving model artifacts, i.e. <base_output_dir>/model/ |
| 3950 | + - AIP_CHECKPOINT_DIR: a Cloud Storage URI of a directory intended for saving checkpoints, i.e. <base_output_dir>/checkpoints/ |
| 3951 | + - AIP_TENSORBOARD_LOG_DIR: a Cloud Storage URI of a directory intended for saving TensorBoard logs, i.e. <base_output_dir>/logs/ |
| 3952 | +
|
3828 | 3953 | service_account (str): |
3829 | 3954 | Specifies the service account for workload run-as account. |
3830 | 3955 | Users submitting jobs must have act-as permission on this run-as account. |
@@ -3866,6 +3991,13 @@ def _run( |
3866 | 3991 | if args: |
3867 | 3992 | spec["pythonPackageSpec"]["args"] = args |
3868 | 3993 |
|
| 3994 | + if environment_variables: |
| 3995 | + env = [ |
| 3996 | + gca_env_var.EnvVar(name=str(key), value=str(value)) |
| 3997 | + for key, value in environment_variables.items() |
| 3998 | + ] |
| 3999 | + spec["pythonPackageSpec"]["env"] = env |
| 4000 | + |
3869 | 4001 | ( |
3870 | 4002 | training_task_inputs, |
3871 | 4003 | base_output_dir, |
|