|
1 | 1 | import logging
|
2 |
| -from typing import Optional |
3 | 2 |
|
4 | 3 | import requests
|
5 | 4 | from truss.remote.baseten.auth import AuthService
|
@@ -59,38 +58,57 @@ def model_s3_upload_credentials(self):
|
59 | 58 |
|
60 | 59 | def create_model_from_truss(
|
61 | 60 | self,
|
62 |
| - model_name, |
63 |
| - s3_key, |
64 |
| - config, |
65 |
| - semver_bump, |
66 |
| - client_version, |
67 |
| - is_trusted=False, |
68 |
| - model_id: Optional[str] = None, |
| 61 | + model_name: str, |
| 62 | + s3_key: str, |
| 63 | + config: str, |
| 64 | + semver_bump: str, |
| 65 | + client_version: str, |
| 66 | + is_trusted: bool, |
69 | 67 | ):
|
70 |
| - if model_id: |
71 |
| - mutation = "create_model_version_from_truss" |
72 |
| - first_arg = f'model_id: "{model_id}"' |
73 |
| - else: |
74 |
| - mutation = "create_model_from_truss" |
75 |
| - first_arg = f'name: "{model_name}"' |
76 |
| - |
77 | 68 | query_string = f"""
|
78 | 69 | mutation {{
|
79 |
| - {mutation}({first_arg}, |
80 |
| - s3_key: "{s3_key}", |
81 |
| - config: "{config}", |
82 |
| - semver_bump: "{semver_bump}", |
83 |
| - client_version: "{client_version}", |
84 |
| - is_trusted: {'true' if is_trusted else 'false'} |
85 |
| - ) {{ |
86 |
| - id, |
87 |
| - name, |
88 |
| - version_id |
| 70 | + create_model_from_truss( |
| 71 | + name: "{model_name}", |
| 72 | + s3_key: "{s3_key}", |
| 73 | + config: "{config}", |
| 74 | + semver_bump: "{semver_bump}", |
| 75 | + client_version: "{client_version}", |
| 76 | + is_trusted: {'true' if is_trusted else 'false'} |
| 77 | + ) {{ |
| 78 | + id, |
| 79 | + name, |
| 80 | + version_id |
| 81 | + }} |
89 | 82 | }}
|
| 83 | + """ |
| 84 | + resp = self._post_graphql_query(query_string) |
| 85 | + return resp["data"]["create_model_from_truss"] |
| 86 | + |
| 87 | + def create_model_version_from_truss( |
| 88 | + self, |
| 89 | + model_id: str, |
| 90 | + s3_key: str, |
| 91 | + config: str, |
| 92 | + semver_bump: str, |
| 93 | + client_version: str, |
| 94 | + is_trusted: bool, |
| 95 | + ): |
| 96 | + query_string = f""" |
| 97 | + mutation {{ |
| 98 | + create_model_version_from_truss( |
| 99 | + model_id: "{model_id}" |
| 100 | + s3_key: "{s3_key}", |
| 101 | + config: "{config}", |
| 102 | + semver_bump: "{semver_bump}", |
| 103 | + client_version: "{client_version}", |
| 104 | + is_trusted: {'true' if is_trusted else 'false'} |
| 105 | + ) {{ |
| 106 | + id |
| 107 | + }} |
90 | 108 | }}
|
91 | 109 | """
|
92 | 110 | resp = self._post_graphql_query(query_string)
|
93 |
| - return resp["data"][mutation] |
| 111 | + return resp["data"]["create_model_version_from_truss"] |
94 | 112 |
|
95 | 113 | def create_development_model_from_truss(
|
96 | 114 | self,
|
|
0 commit comments