Unified query api#158
Open
bmaranville wants to merge 8 commits intomainfrom
Open
Conversation
…al based on settings
….update_db = False
Contributor
Author
|
The corresponding PR to remove the functions that were copied from SLDDB to here has not been made yet... in the SLDDB server code they'll be replaced by imports from here. |
aglavic
reviewed
Apr 7, 2026
Collaborator
aglavic
left a comment
There was a problem hiding this comment.
Good idea to put this all in one place. I'd not remove the default webquery, though.
| m = db.select_material(entry) | ||
| loaded_ids[ID] = m | ||
| elements.append(number * loaded_ids[ID]) | ||
| result = elements[0] |
Collaborator
There was a problem hiding this comment.
Can't this be simply return sum(elements) ?
| result += element | ||
| return result | ||
|
|
||
|
|
Collaborator
There was a problem hiding this comment.
I'd propose to do this simply by using a dictionary of collect functions and .get:
COLLECT_FUNCTIONS = {
"protein": collect_protein,
"dna": collect_dna,
"rna": collect_rna,
"db": collect_blendIDs,
}|
|
||
| def __init__(self): | ||
| self.first_access = True | ||
| self.use_webquery = True # only try webquery once, if error occurs switch to local database |
Collaborator
There was a problem hiding this comment.
Making the default just a DB download will break the SLDdb statistical functions that are used to improve search results. (I.e. return most searched and most selected materials, first.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In this PR
SLD_API.search(**opts)webqueryandblenderare moved from the SLDDB codebase to here (orsopy.slddb)SLD_API.localqueryis refactored so it takes the sameqdictargument aswebquerySLD_API.use_webquerydefaults to FalseSLD_API.update_dbdefaults to Truewebqueryto the SLDDB server (ifapi.use_webquery == True) orlocalquery, using the local copy of thedbfileDefault configuration
The combination of
use_webquery=Falseandupdate_db=Truemeans that, in the default configuration, this will happen:max_age, a new copy is downloaded from the SLDDB serverSLDDB-server independent configuration
If you set
SLD_API.update_db = Falsebefore your first search (typically by doingorsopy.slddb.api.update_db = False), then no attempt is made to download a new copy of the database, and you use the version you currently have.Webquery-preferred configuration
This is the currently the default in the released
orsopy-orsopy.slddb.api.use_webquery = True, and it only falls back to the local db if thewebqueryfails. Every lookup then goes to the central SLDDB server.