-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Issue creating allocations using coldfront shell #603
Comments
To give some further troubleshooting information: I deleted all the broken allocations from the database:
Then I performed the following steps: racs = Project.objects.get(title="racs")
active = AllocationStatusChoice.objects.get(name="Active")
Allocation.objects.create(project=racs, status=active) Which returns:
But the entry gets created in the database:
However when I go query the Allocation objects:
That breaks. I also receive a "We're having a bit of system trouble at the moment. Please check back soon!" if I try to delete the allocation from the django admin interface. Looking into the error, it's failing to call the Unfortunately I can't assign resources like so: >>> Allocation.objects.create(project=racs, status=active, resources=[])
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/srv/coldfront/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/srv/coldfront/venv/lib/python3.11/site-packages/django/db/models/query.py", line 451, in create
obj = self.model(**kwargs)
^^^^^^^^^^^^^^^^^^^^
File "/srv/coldfront/venv/lib/python3.11/site-packages/django/db/models/base.py", line 498, in __init__
_setattr(self, prop, kwargs[prop])
File "/srv/coldfront/venv/lib/python3.11/site-packages/django/db/models/fields/related_descriptors.py", line 545, in __set__
raise TypeError(
TypeError: Direct assignment to the forward side of a many-to-many set is prohibited. Use resources.set() instead. But I can fix it like so: >>> r = Resource.objects.get(name="Talapas2")
>>> r
<Resource: Talapas2 (Cluster)>
>>> a = Allocation.objects.get(project=racs)
>>> a
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/srv/coldfront/venv/lib/python3.11/site-packages/django/db/models/base.py", line 521, in __repr__
return '<%s: %s>' % (self.__class__.__name__, self)
^^^^
File "/srv/coldfront/venv/lib/python3.11/site-packages/coldfront/core/allocation/models.py", line 343, in __str__
return "%s (%s)" % (self.get_parent_resource.name, self.project.pi)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'name'
>>> a.resources.set([r])
>>> a.save()
>>> a
<Allocation: Talapas2 (dmajchrz)> This allocation seems to be working. This may just be a lack of understanding on how to create django objects with complex relationships. I'd love if the Importing Data documentation could be updated with examples of how to create all those resource types using raw python, like you have listed for the Adding Users to Allocations section. I'm really looking forward to #316, but in the mean time you gotta do whatcha gotta do 😊 I wish I could help with that request, but I'm booked solid until July. I've opened a PR that includes a proposed fix to silence the error from this issue. Probably not the best way to go about it, but it should work. |
What happened?
I'm working through a sync tool to sync our site data from AD/Slurm into Coldfront in preparation for a cutover in the future.
I've been successful creating users, projects, project users, and resources, but I'm running into an error while creating Allocations that I'm unsure how to work around:
I'm not a big django guy but it looks like it's failing to create it because the
project
model usestitle
rather thanname
?If this isn't a bug, could you please provide some direction on how I can create an Allocation using the coldfront shell?
Thanks!!
Version
1.1.5
Component
Allocations
What browsers are you seeing the problem on?
None
Relevant log output
Tasks/ user tests when bug is fixed
The text was updated successfully, but these errors were encountered: