Minor improvement on cbloader & Rename api.load() arg data to options#336
Conversation
The param `representation` of `avalon.pipeline.get_representation_context()`, which used by `avalon.api.load`, actually accept not only representation id but also full representation object, so this commit can reduce one database query per load.
|
Thanks! Isn't this actually incorrect? Isn't it so that the Also, I wouldn't explicitly pass |
|
Correct me if I am wrong, in my understanding, And the one who responsible to acquire def get_representation_context(representation):
if isinstance(representation, (str, ObjectId)):
representation = io.find_one({"_id": ObjectId(str(representation))})
# acquire context
...
return context
def load(Loader, representation, namespace=None, name=None, data=None):
...
context = get_representation_context(representation)
...The argument Thus,
Sounds like we have different future use case on this ?
Yes, but I did write something to the Thanks for the reply @BigRoy :) |
|
Hey, I am back on this :) But I am still not quite understand on this :
Isn't that right the Thanks! |
|
I think what Roy is saying is that the The reason it isn't passed at the moment, is because there aren't any options for this particular tool, is that right @BigRoy? Does that make sense @davidlatwe? |
Yes, that is what I meant. The explicit
If it technically works it's fine with me - I just recalled that the API wasn't intended to function that way but might have assumed wrong and jumped the gun on the answer. The issue regarding the You can find it in the representation = context["representation"]
data = representation["data"]That's what I meant with the fact that you wouldn't need to pass that explicitly, that particular data is already available to you in the load method. Making this change in code redundant, correct? Does that help? |
|
Renaming """
Arguments:
name (str): Name of subset
asset (str): Name of asset
family (str): Name of family
options (dict, optional): Additional options from GUI
data (dict, optional): Additional data from GUI
"""I did not take too much attention on |
api.load() arg data to options
|
I tweaked my PR, added argument renaming ( What do you think ? |
| data = dict() | ||
| # Ensure options is a dictionary when no explicit options provided | ||
| if options is None: | ||
| options = kwargs.get("data", dict()) # "data" for backward compact |
There was a problem hiding this comment.
backward compact should be backward compatibility or maybe backward compat if you really want it shorter? :)
|
Sorry, I thought I replied to this. This looks good to me if it works. :) Just commented on one minor typo. @aardschok what do you think? @davidlatwe Nice work! |
|
I have no objections to this, nice work! |
|
Thanks ! I got them fixed :P |
|
|
|
Are these latest commits supposed to be part of the same PR? |
|
Sorry, that should be separate. |
|
Okay it's done, I'll put that (pin sphinx==1.7.9) in next PR alone, sorry for the trouble 😢 |
|
Please merge #338 first and I will rebase this PR so the travis will pass :) |
|
I think it's okay to merge now. |
|
Thanks @davidlatwe! |
…nager-shows-deleted-Harmony Feature #1191 subset manager shows deleted harmony
Little changes...
Motivation
I use
cbloaderand thedataof representation object is required but the tool did not pass it.Implementation
Add one line to extract
datafrom representation and pass toapi.load.Also, I noticed that instead passing the
ObjectIdof representation toapi.load, directly pass the representation object can reduce one database query, since the functionget_representation_contextwhich been used here, is able to accept both form.