Skip to content
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

explainables().ownerships() method throws a TypeError exception #599

Open
izmalk opened this issue Feb 14, 2024 · 0 comments
Open

explainables().ownerships() method throws a TypeError exception #599

izmalk opened this issue Feb 14, 2024 · 0 comments

Comments

@izmalk
Copy link
Member

izmalk commented Feb 14, 2024

Description

ConceptMap.explainables().ownerships() throws a Type error, but it doesn't have any arguments.

Environment

  1. TypeDB distribution: Core
  2. TypeDB version: 2.26.6-rc1
  3. Environment: Mac
  4. Studio version: -
  5. Other details: Python driver 2.26.6-rc1

Reproducible Steps

  1. Set up
            define_query = """
                            define
                            email sub attribute, value string;
                            name sub attribute, value string;
                            friendship sub relation, relates friend;
                            user sub entity,
                                owns email @key,
                                owns name,
                                plays friendship:friend;
                            admin sub user;
                            """

            define_query_rule = """
                            define
                            rule users:
                            when {
                                $u isa user;
                            } then {
                                $u has name "User";
                            };
                            """
            insert_query = """
                            insert
                            $user1 isa user, has name "Alice", has email "alice@vaticle.com";
                            $user2 isa user, has name "Bob", has email "bob@vaticle.com";
                            $friendship (friend:$user1, friend: $user2) isa friendship;
                            """

with driver.session(DB_NAME, SessionType.DATA) as session:
        with session.transaction(TransactionType.READ, TypeDBOptions(infer=True, explain=True)) as transaction:
            get_query = """
                            match
                            $u isa user, has email $e, has name $n;
                            $e contains 'Alice';
                            get
                            $u, $n;
                            """
  1. Execute
response = transaction.query.get(get_query)
for i, ConceptMap in enumerate(response):
    name = ConceptMap.get("n").as_attribute().get_value()
    print(f"Name #{i + 1}: {name}")
    explainable_ownerships = ConceptMap.explainables().ownerships()
  1. Unexpected result
Traceback (most recent call last):
  File "/Users/vladimir/Documents/GitHub/typedb_python_driver_manual/main.py", line 230, in <module>
    explainable_ownerships = ConceptMap.explainables().ownerships()
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vladimir/Documents/GitHub/python_features_code_test/venv/lib/python3.11/site-packages/typedb/concept/answer/concept_map.py", line 139, in ownerships
    return {key: self.ownership(*key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/vladimir/Documents/GitHub/python_features_code_test/venv/lib/python3.11/site-packages/typedb/concept/answer/concept_map.py", line 139, in <dictcomp>
    return {key: self.ownership(*key)
                 ^^^^^^^^^^^^^^^^^^^^
TypeError: typedb.concept.answer.concept_map._ConceptMap.Explainables.ownership() argument after * must be an iterable, not StringPair

Expected result

Return Explainable for every ownership.
https://typedb.com/docs/drivers/python/api-reference#Explainables_ownerships_

Additional information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant