MCPcopy Create free account
hub / github.com/IQEngine/IQEngine / create

Function create

api/database/metadata_repo.py:91–123  ·  view source on GitHub ↗

Create a new metadata. The metadata will be henceforth identified by account/container/filepath which must be unique or this function will throw an exception. This function will also create a new version of the metadata in the versions collection. Parameters ---------- met

(metadata: Metadata)

Source from the content-addressed store, hash-verified

89
90
91async def create(metadata: Metadata):
92 """
93 Create a new metadata. The metadata will be henceforth identified by account/container/filepath which
94 must be unique or this function will throw an exception.
95
96 This function will also create a new version of the metadata in the versions collection.
97
98 Parameters
99 ----------
100 metadata : Metadata
101 The metadata to create.
102
103 Returns
104 -------
105 None
106 """
107 if metadata.globalMetadata.traceability_origin is None:
108 raise Exception("Metadata must have origin")
109
110 if await exists(
111 metadata.globalMetadata.traceability_origin.account,
112 metadata.globalMetadata.traceability_origin.container,
113 metadata.globalMetadata.traceability_origin.file_path,
114 ):
115 raise Exception("Metadata Already Exists")
116
117 metadata_collection: AgnosticCollection = collection()
118 versions: AgnosticCollection = versions_collection()
119
120 await metadata_collection.insert_one(
121 metadata.dict(by_alias=True, exclude_unset=True)
122 )
123 await versions.insert_one(metadata.dict(by_alias=True, exclude_unset=True))
124
125
126class InvalidGeolocationFormat(Exception):

Callers

nothing calls this directly

Calls 3

versions_collectionFunction · 0.85
existsFunction · 0.70
collectionFunction · 0.70

Tested by

no test coverage detected