You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bioimageio/spec/_upload.py
+40-14Lines changed: 40 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,5 @@
1
+
importcollections.abc
2
+
importio
1
3
fromtypingimportUnion
2
4
fromzipfileimportZipFile
3
5
@@ -15,6 +17,7 @@
15
17
from ._internal.common_nodesimportResourceDescrBase
16
18
from ._internal.ioimportBioimageioYamlContent, get_reader
17
19
from ._internal.io_basicsimportBIOIMAGEIO_YAML
20
+
from ._internal.io_utilsimportwrite_yaml
18
21
from ._packageimportget_resource_package_content
19
22
from .commonimportPermissiveFileSource
20
23
@@ -56,24 +59,36 @@ def upload(
56
59
ifisinstance(descr, InvalidDescr):
57
60
raiseValueError("Uploading invalid resource descriptions is not allowed.")
58
61
62
+
ifdescr.type!="model":
63
+
raiseNotImplementedError(
64
+
f"For now, only model resources can be uploaded (got type={descr.type})."
65
+
)
66
+
67
+
ifdescr.idisnotNone:
68
+
raiseValueError(
69
+
"You cannot upload a resource with an id. Please remove the id from the description and make sure to upload a new non-existing resource. To edit an existing resource, please use the web interface at https://bioimage.io."
70
+
)
71
+
59
72
content=get_resource_package_content(descr)
60
73
61
-
manifest=content.pop(BIOIMAGEIO_YAML)
62
-
assertisinstance(manifest, dict)
74
+
metadata=content[BIOIMAGEIO_YAML]
75
+
assertisinstance(metadata, dict)
76
+
manifest=dict(metadata)
77
+
78
+
# only admins can upload a resource with a version
79
+
artifact_version="stage"# if descr.version is None else str(descr.version)
0 commit comments