Skip to content

Commit

Permalink
Got package variant installed to mongo package repository with no errors
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce Gattis <[email protected]>
  • Loading branch information
BryceGattis committed Mar 3, 2024
1 parent 698d44f commit a072193
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/rezplugins/package_repository/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import os
import time
from tempfile import NamedTemporaryFile
from urllib.parse import quote_plus
import datetime
from tempfile import gettempdir
Expand All @@ -17,8 +16,6 @@
from rez.package_repository import PackageRepository
from rez.package_resources import PackageFamilyResource, VariantResourceHelper,\
PackageResourceHelper, package_pod_schema, VariantResource
from rez.package_serialise import dump_package_data
from rez.serialise import load_from_file, FileFormat
from rez.utils.resources import cached_property, ResourcePool

from pymongo import MongoClient
Expand Down Expand Up @@ -128,13 +125,7 @@ def _load(self):
res = self._repository.packages.find_one({"name": self.name, "version": self.get("version")})
if not res:
return {}

file = NamedTemporaryFile(prefix=self.name, suffix=".py").name

with open(file, "w") as stream:
dump_package_data(res.get("data"), stream)

return load_from_file(file, FileFormat.py)
return res.get("data")


class MongoVariantResource(VariantResourceHelper):
Expand Down Expand Up @@ -269,7 +260,7 @@ def _get_variant_document(self, variant_resource: VariantResource, overrides=Non
post.update(overrides)
# We need to convert all data to string representation, so it can be added to the DB. Maybe there's a
# built-in way to do this in Rez?
str_data = {k: str(v) for k, v in data.items()}
str_data = {k: str(v) for k, v in data.items() if v is not None}
post["data"] = str_data
post["timestamp"] = datetime.datetime.utcnow()

Expand Down

0 comments on commit a072193

Please sign in to comment.