usnistgov / dioptra

Test Software for the Characterization of AI Technologies
https://pages.nist.gov/dioptra/
Other
229 stars 34 forks source link

[BUG] ORM object reprs are excessively large #656

Closed chisholm closed 1 week ago

chisholm commented 1 month ago

Describe the bug The repr of a single object can be enormous.

To Reproduce Steps to reproduce the behavior:

You can try the following script:

# This creates 10 queues each of which has 3 tags randomly chosen from a
# set of 10.
import random
import dioptra.restapi.db.models as m

user = m.User("name", "password", "user@example.org")
group = m.Group("groupname", user)

tags = [m.Tag(f"tag_{i}", group, user) for i in range(10)]

queues = []
for i in range(10):
    res = m.Resource("queue", group)
    queues.append(m.Queue("a queue", res, user, f"queue_{i}"))

for queue in queues:
    queue.tags.extend(random.sample(tags, k=3))

print(repr(queues[0]))

This will repr one of the queues so created. You'll want to redirect the output to a file and wait a bit. I've run this a couple times; both times, the resulting file was over 1GB in size!

Expected behavior

A reasonably sized repr.

jkglasbrenner commented 1 week ago

Closed by #657