TACTIC Open Source
self to self relationship - Printable Version

+- TACTIC Open Source (http://forum.southpawtech.com)
+-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3)
+--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4)
+--- Thread: self to self relationship (/showthread.php?tid=29)

Pages: 1 2 3 4


RE: self to self relationship - remkonoteboom - 11-18-2019

My mistake. I did mean:

assets = server.eval("@SOBJECT(dolly3d/assets.dolly3d/assets_in_assets)", skey)

Ok, so this gives you one assets_in_assets back with code "ASSETS_IN_ASSETS00017" which is the only one you have in the database. It seems to have given you the relationship as a parent, which I believe is the first one in your schema.

Does:

assets = server.eval("@SOBJECT(dolly3d/assets.parent:dolly3d/assets_in_assets)", skey)

give you the same result?


RE: self to self relationship - listy - 11-18-2019

No. It just returning me:
[{'__search_key__': 'dolly3d/assets?project=dolly3d&code=ASSETS00577',
'__search_type__': 'dolly3d/assets?project=dolly3d',
'assets_category_code': 'locations',
'code': 'ASSETS00577',
'description': '',
'id': 577,
'keywords': '',
'login': '',
'name': 'witch_house_inside',
'pipeline_code': 'dolly3d/assets',
'relative_dir': 'dolly3d/assets',
's_status': '',
'texture_drop': '',
'timestamp': '2019-10-11 20:05:58.005634'}]

I Think I should try this with Tactic 4.7. May be 4.5 have some bugs.
Or may be it is because of Assets Category. My full schema:
<?xml version="1.0" encoding="UTF-8"?>
<schema>
<search_type name="complex/assets_category" xpos="522" ypos="236"/>
<search_type name="complex/scenes" xpos="303" ypos="327"/>
<search_type name="complex/shot" xpos="303" ypos="415"/>
<search_type name="dolly3d/assets" xpos="303" ypos="236"/>
<search_type name="dolly3d/assets_in_assets" xpos="622" ypos="445"/>
<search_type name="dolly3d/assets_in_scenes" xpos="100" ypos="282"/>
<search_type name="dolly3d/texture" xpos="423" ypos="100" display="Texture"/>
<search_type name="dolly3d/texture_in_assets" xpos="102" ypos="100"/>
<connect from="complex/scenes" to="dolly3d/assets" instance_type="dolly3d/assets_in_scenes" relationship="instance"/>
<connect from="complex/shot" to="complex/scenes" relationship="code" from_col="scenes_code" to_col="code" type="hierarchy"/>
<connect from="dolly3d/assets" to="complex/assets_category" relationship="code" from_col="assets_category_code" to_col="code" type="hierarchy"/>
<connect from="dolly3d/assets" to="complex/scenes" instance_type="dolly3d/assets_in_scenes" relationship="instance"/>
<connect from="dolly3d/assets" to="dolly3d/texture" instance_type="dolly3d/texture_in_assets" relationship="instance"/>
<connect from="dolly3d/assets" to="dolly3d/assets" instance_type="dolly3d/assets_in_assets" relationship="instance"/>
<connect from="dolly3d/assets_in_assets" to="dolly3d/assets" relationship="code" from_col="parent_assets_code" to_col="code" type="many_to_many"/>
<connect from="dolly3d/assets_in_assets" to="dolly3d/assets" relationship="code" from_col="child_assets_code" to_col="code" type="many_to_many"/>
<connect from="dolly3d/assets_in_scenes" to="complex/scenes" relationship="code" type="many_to_many"/>
<connect from="dolly3d/assets_in_scenes" to="dolly3d/assets" relationship="code" from_col="assets_code" to_col="code" type="many_to_many"/>
<connect from="dolly3d/texture" to="complex/assets_category" relationship="code" from_col="assets_category_code" to_col="code" type="hierarchy"/>
<connect from="dolly3d/texture" to="dolly3d/assets" instance_type="dolly3d/texture_in_assets" relationship="instance"/>
<connect from="dolly3d/texture_in_assets" to="dolly3d/texture" relationship="code" from_col="texture_code" to_col="code" type="many_to_many"/>
<connect from="dolly3d/texture_in_assets" to="dolly3d/assets" relationship="code" from_col="assets_code" to_col="code" type="many_to_many"/>
</schema>


RE: self to self relationship - listy - 11-19-2019

Help Me Please ;(


RE: self to self relationship - remkonoteboom - 11-19-2019

The return value you are getting doesn't make sense. It shouldn't return a "dolly3d/assets" list ... it should return a "dolly3d/assets_in_assets" list or at list an empty list if no results are found.

In src/pyasm/search/search.py we have the code:

2127 search.add_relationship_filters(sobjects, path=path)
2128 related_sobjects = search.get_sobjects()

If you could add in between these lines:

print("related_search: ", search.get_statement())

we can see exactly what sql is being called. That would be really helpful.


RE: self to self relationship - remkonoteboom - 11-20-2019

I just added this to the vfx project:

<search_type name="vfx/asset_in_asset" xpos="528" ypos="187"/>
<connect from="vfx/asset_in_asset" to="vfx/asset" from_node="vfx/asset_in_asset" to_node="vfx/asset" relationship="code" from_col="parent_asset_code" to_col="code" path="parent"/>
<connect from="vfx/asset_in_asset" to="vfx/asset" from_node="vfx/asset_in_asset" to_node="vfx/asset" relationship="code" from_col="child_asset_code" to_colr="code" path="child"/>

And then wrote a quick test script:

import tacticenv

from pyasm.security import Batch

Batch(project_code="my_first_project")

from pyasm.search import Search
skey = "vfx/asset?project=my_first_project&code=ASSET00002"
asset = Search.get_by_search_key(skey)
assets = Search.eval("@SOBJECT(parent:vfx/asset_in_asset.child:vfx/asset)", asset)
for asset in assets:
print(asset.get_search_key())

This produced the correct result ... mind you this was in 4.7 using python3.


RE: self to self relationship - listy - 11-20-2019

Hello, Remko!
I know that You have 10 dan black belt in tactic, and expected some black magic from Tou, and there it is. Now everything working as expected, and i learned some new Schema features. Thanks a lot!
This is what i did:
<connect from="dolly3d/assets_in_assets" to="dolly3d/assets" from_node="dolly3d/assets_in_assets" to_node="dolly3d/assets" relationship="code" from_col="parent_assets_code" to_col="code" path="parent"/>
<connect from="dolly3d/assets_in_assets" to="dolly3d/assets" from_node="dolly3d/assets_in_assets" to_node="dolly3d/assets" relationship="code" from_col="child_assets_code" to_colr="code" path="child"/>

And now this returning me what i need:
server.set_project('dolly3d')
skey = ['dolly3d/assets?project=dolly3d&code=ASSETS00577']
server.eval("@SOBJECT(parent:dolly3d/assets_in_assets.child:dolly3d/assets)", search_keys=skey)


RE: self to self relationship - listy - 02-06-2020

Another question about related.
When i do TEL query - everything ok. But how i can do this with Search?

Trying to do this:
from pyasm.search import Search

server.set_project('testovy')

search_key = 'testovy/asset?project=testovy&code=ASSET00002'

search_type, search_code = server.split_search_key(search_key)
search = Search(search_type)
sobject = search.get_by_search_key(search_key)

related_sobjects = sobject.get_related_sobjects('testovy/asset_in_asset')

I got "Fault: <Fault 1: 'Search type [testovy/asset_in_asset?project=testovy] is not related to search_type [testovy/asset?project=testovy]'>

"


RE: self to self relationship - remkonoteboom - 02-06-2020

This is entirely determined by the schema entry for your project. Your last example was with the project "dolly3d". this example is with "testovy". Are the schemas different for these two projects. In particular, does "testovy" have a line that conncects "asset" to "asset_in_asset"?


RE: self to self relationship - listy - 02-06-2020

(02-06-2020, 03:28 PM)remkonoteboom Wrote: This is entirely determined by the schema entry for your project.  Your last example was with the project "dolly3d".  this example is with "testovy".  Are the schemas different for these two projects.  In particular, does "testovy" have a line that conncects "asset" to "asset_in_asset"?
It is the same. Schema is identical. Only names are different.

@SOBJECT(child:testovy/asset_in_asset['child_asset_code', 'ASSET00002'].parent:testovy/asset)

TEL which works fine.

Schema:
<connect from="testovy/asset" to="testovy/asset" instance_type="testovy/asset_in_asset" relationship="instance"/>
<connect from="testovy/asset_in_asset" to="testovy/asset" relationship="code" from_col="parent_asset_code" to_col="code" path="parent" type="many_to_many"/>
<connect from="testovy/asset_in_asset" to="testovy/asset" relationship="code" from_col="child_asset_code" to_col="code" path="child" type="many_to_many"/>


RE: self to self relationship - remkonoteboom - 02-06-2020

I think it's because TEL is using a slightly different mechanism:

search_key = 'testovy/asset?project=testovy&code=ASSET00002'
search_type, search_code = server.split_search_key(search_key)
search = Search(search_type)
search.add_filter("code", search_code)

search2 = Search("testovy/asset_in_asset")
search2.add_relationship_search_filter(search)
related_sobjects = search2.get_sobjects()

This is more efficient because it never needs to get the first sobject. It is all done in a single SQL call.
You can see that "search" can be arbitrarily complex and it will use a subselect into the second search.

Could you see if that works? It will help me pinpoint the bug in get_related_sobjects() (which should work).