RelationalAI / rai-sdk-python

The RelationalAI Software Development Kit (SDK) for Python.
Apache License 2.0
17 stars 4 forks source link

Disjunction Operator not working as expected #43

Closed mariabaladuggimpudi closed 2 years ago

mariabaladuggimpudi commented 2 years ago

I have the following files:

source.rel data_model.py

The contents of the data_model.py are as follows:

from argparse import ArgumentParser import json from os import path from urllib.request import HTTPError from railib import api, config, show import datetime

def _sansext(fname: str) -> str:

print(path)

return path.splitext(path.basename(fname))[0]

def run(database: str, engine: str, fname: str, profile: str) -> None: sources = {} with open(fname) as fp: sources[_sansext(fname)] = fp.read() # source name => source cfg = config.read(profile=profile) ctx = api.Context(**cfg)

# Creating the database
rsp_database = api.create_database(
    ctx, database, engine, overwrite=True)
print(json.dumps(rsp_database, indent=2))

# Uploading the data and data modeling by using install source
rsp_model_data = api.install_source(ctx, database, engine, sources)
print(json.dumps(rsp_model_data, indent=2))

# Querying the database
rsp_query_json_clli = api.query(
    ctx, database, engine, "op", readonly=True)
show.results(rsp_query_json_clli)
# print(json.dumps(rsp_query_json_clli, indent=2))

if name == "main": local_path = '/home/raiserver/raicode_workspace/att-addra/relsrc/' p = ArgumentParser() p.add_argument("database", type=str, help="database name", choices=["addra-db-2", "addra-db"], nargs='?', default="addra-db-2") p.add_argument("engine", type=str, help="engine name", choices=["engine", "localhost"], nargs='?', default="engine") p.add_argument("file", type=str, help="source file", choices=["modeling.rel", "source.rel"], nargs='?', default="source.rel") p.add_argument("-p", "--profile", type=str, help="profile name", default="local") args = p.parse_args() try: run(args.database, args.engine, local_path + args.file, args.profile) except HTTPError as e: show.http_error(e)

The content of the file source.rel is as follows:

def directional_flight = { ("Providence (PVD)", "Boston (BOS)"); ("Boston (BOS)", "San Francisco (SFO)"); ("San Francisco (SFO)", "Honolulu (HNL)"); ("New York (JFK)", "Los Angeles (LAX)"); }

def flight_a(a, b) = directional_flight(a, b) or directional_flight(b, a)

def flight(a, b) = directional_flight(b, a) def flight(b, a) = directional_flight(a, b)

def op = count[flight_a] def op = count[flight]

The expected count for both the relations flight_a and flight is 8 each. But the SDK returns 8 for flight_a and 4 for flight relations

billscheidel-rai commented 1 year ago

Note: This issue has been migrated to https://relationalai.atlassian.net/browse/RAI-4058.

This link is only accessible to employees of RelationalAI.