File tree Expand file tree Collapse file tree 2 files changed +509
-157
lines changed
Expand file tree Collapse file tree 2 files changed +509
-157
lines changed Original file line number Diff line number Diff line change 99# - [ ] Support lazy downloading of files into Path
1010# - [ ] Support helpers for working with ContatenateIterator
1111import inspect
12+ import os
1213from dataclasses import dataclass
1314from functools import cached_property
1415from typing import Any , Dict , Optional , Tuple
@@ -26,10 +27,9 @@ def _in_module_scope() -> bool:
2627 """
2728 Returns True when called from top level module scope.
2829 """
29- import os
3030 if os .getenv ("REPLICATE_ALWAYS_ALLOW_USE" ):
3131 return True
32-
32+
3333 if frame := inspect .currentframe ():
3434 if caller := frame .f_back :
3535 return caller .f_code .co_name == "<module>"
@@ -172,8 +172,13 @@ def openapi_schema(self) -> dict[Any, Any]:
172172 """
173173 Get the OpenAPI schema for this model version.
174174 """
175- schema = self ._model .latest_version .openapi_schema
176- if cog_version := self ._model .latest_version .cog_version :
175+ latest_version = self ._model .latest_version
176+ if latest_version is None :
177+ msg = f"Model { self ._model .owner } /{ self ._model .name } has no latest version"
178+ raise ValueError (msg )
179+
180+ schema = latest_version .openapi_schema
181+ if cog_version := latest_version .cog_version :
177182 schema = make_schema_backwards_compatible (schema , cog_version )
178183 return schema
179184
You can’t perform that action at this time.
0 commit comments