pytorch-lightning

Форк
0
41 строка · 1.5 Кб
1
# Copyright The Lightning AI team.
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
from typing import Dict, Iterable
16

17
from lightning.app.utilities.cloud import _get_project
18
from lightning.app.utilities.network import LightningClient
19

20

21
def _names_to_ids(secret_names: Iterable[str]) -> Dict[str, str]:
22
    """Returns the name/ID pair for each given Secret name.
23

24
    Raises a `ValueError` if any of the given Secret names do not exist.
25

26
    """
27
    lightning_client = LightningClient()
28

29
    project = _get_project(lightning_client)
30
    secrets = lightning_client.secret_service_list_secrets(project_id=project.project_id)
31

32
    secret_names_to_ids: Dict[str, str] = {}
33
    for secret in secrets.secrets:
34
        if secret.name in secret_names:
35
            secret_names_to_ids[secret.name] = secret.id
36

37
    for secret_name in secret_names:
38
        if secret_name not in secret_names_to_ids:
39
            raise ValueError(f"Secret with name '{secret_name}' not found")
40

41
    return secret_names_to_ids
42

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.