Comments (12)
Thank you for sharing the additional information. I also realized now that the get_prep_value
implementation you included in this ticket description is different from the one you posted with the original rdkit issue.
bulk_update
works differently than a plain update (there are a few explicitly documented caveats), which is probably related to why Func
may not work in this case. At the same time, mol_from_pkl
might be unnecessary in the given context, but I'll try to perform a few tests during the next days.
from django-rdkit.
As discussed in the rdkit issue #5344, why your fix would work is a bit unclear to me, and the ticket is unfortunately not providing a clear description of the problem you had to solve. Could you please provide some additional information with regard to what query is executed, what trouble you experienced with the original implementation (what is more exactly the error, or unexpected behavior?) and what input value
is passed?
Additional details about what version of django-rdkit was used, any modifications applying to it, versions of django, postgresql, rdkit (for both the web application and database cartridge) would also help.
from django-rdkit.
I have trouble by using bulk_update
method of django ORM.
When I try use bulk_update
with default implementation of get_prep_value
I catch exception cant adapt Func
.
When I using my implementation all work correctly.
But I'm not shour about correct work of other features of Mol field
from django-rdkit.
@rvianello if you could adress this quickly, I think the fix of @ivannnnnnnnnn would also allow older versions of the cartridge to be compatible with up to date versions of rdkit (on the django-rdkit/django app side). Based on what I currently understand, the reason is that a Mol from a future version of rdkit is not picklable by a MolPickler version of an older version of rdkit (that doesn't have the right MolPickler version). However, with the fix of @ivannnnnnnnnn , since the mol_from_pkl is not called on the binary value, the DB accepts it, and all the functions work properly on the db side.
However, this is the part I don't understand fully yet: Why, once the binary gets inserted in the db (without mol_from_pkl), everything seems to work perfectly: functions on the db side (including mol_from_pkl???), deserialization from a django backend using django-rdkit, etc ? . We currently use the cartridge only for similarity, substruct and exact searches on a set of molecules, and to keep conformer information of molecules, maybe there are some cases where it wouldn't work.
Small comment on @ivannnnnnnnnn fix, I think this would be more explicit:
def get_prep_value(self, value):
# convert the Molecule instance to the value used by the
# db driver
if isinstance(value, str):
value = self.text_to_mol(value)
if not isinstance(value, Chem.Mol):
return None
return value.ToBinary()
related conversations:
Thanks in advance @rvianello , and I'm happy to make the PR if this fix works (or let ivan do it)
cc @greglandrum if you think you can give context into why this change works
from django-rdkit.
Gentle poke here ☝️
from django-rdkit.
Gentle repoke here ☝️ (I know this is summer and you might be in vacation @rvianello ) , I'll just regularly check up here because this is sort of blocking for us at the moment
from django-rdkit.
@MichelML I hope I will be able to look into this in better detail starting tomorrow (sorry about the slow feedback, I'm just short on time)
from django-rdkit.
Thanks for the update @rvianello ! Totally understand
from django-rdkit.
@ivannnnnnnnnn @MichelML I've spent a bit of time on this during the past few days and I could easily reproduce the issue with the bulk_update
method. Apparently, the new field values are passed directly to the db driver, which results in the can't adapt type 'Func'
error message. On the other hand, not wrapping the value in a call to mol_from_pkl
as you suggested, at the moment breaks some substructure lookup tests, and I'm therefore working on a refactoring that would consider the Lookup
classes too.
from django-rdkit.
@ivannnnnnnnnn @MichelML I think PR #26 should fix the issue with the bulk update of MolField. It would be really great if you could find some time to test it and let me know how it works (I'll try to address the problem related to the client/server rdkit version separately).
from django-rdkit.
@ivannnnnnnnnn @MichelML I think PR #26 should fix the issue with the bulk update of MolField. It would be really great if you could find some time to test it and let me know how it works (I'll try to address the problem related to the client/server rdkit version separately).
Thank you. I will try to use this in my project on next week and write feedback here
from django-rdkit.
thanks a lot @rvianello!
I left a comment and approved the PR! Sorry for last week I was in vacation.
Thanks for taking the time again
from django-rdkit.
Related Issues (20)
- Recent install on Mac unusable due to Python ImportError HOT 1
- Issue with Django 3 HOT 4
- Exact structure searches HOT 3
- Django Gist Index HOT 4
- New release for conda-forge package HOT 2
- Issue with migrate HOT 2
- Error preventing to move to django 4 (ugettext_lazy no longer supported)
- Migrations with Fingerprint Fields
- RDKit 2021.09 compatibility HOT 4
- problem generating molecule from blob data HOT 4
- Unable to set cartridge parameters through django_rdkit.config HOT 1
- MolField hassubstruct perfomance for complex molecules
- Using mol_adjust_query_properties()
- QMOL field
- Release as package on PyPI
- Unique molfield error HOT 6
- Where to set do_chiral_sss? HOT 5
- NameError: name 'forms' is not defined HOT 1
- PyPI package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-rdkit.