diff --git a/examples/show_problems.py b/examples/show_problems.py index 6fd60c2..79d136b 100644 --- a/examples/show_problems.py +++ b/examples/show_problems.py @@ -23,7 +23,7 @@ def run(database: str, engine: str, profile: str): cfg = config.read(profile=profile) ctx = api.Context(**cfg) - rsp = api.exec(ctx, database, engine, "def output = **nonsense**") + rsp = api.exec(ctx, database, engine, "def output { **nonsense** }") show.problems(rsp) diff --git a/examples/show_results.py b/examples/show_results.py index 5ccf2ea..6ff991e 100644 --- a/examples/show_results.py +++ b/examples/show_results.py @@ -24,7 +24,7 @@ def run(database: str, engine: str, profile: str): cfg = config.read(profile=profile) ctx = api.Context(**cfg) - rsp = api.exec(ctx, database, engine, "def output = 'a'; 'b'; 'c'") + rsp = api.exec(ctx, database, engine, "def output { 'a'; 'b'; 'c' }") show.results(rsp) diff --git a/railib/api.py b/railib/api.py index 69eeebe..8970330 100644 --- a/railib/api.py +++ b/railib/api.py @@ -336,7 +336,7 @@ def poll_with_specified_overhead( if start_time is None: start_time = time.time() - + tries = 0 max_time = time.time() + timeout if timeout else None @@ -345,7 +345,7 @@ def poll_with_specified_overhead( break current_time = time.time() - + if max_tries is not None and tries >= max_tries: raise Exception(f'max tries {max_tries} exhausted') @@ -354,8 +354,8 @@ def poll_with_specified_overhead( duration = (current_time - start_time) * overhead_rate duration = min(duration, max_delay) - - time.sleep(duration) + + time.sleep(duration) tries += 1 @@ -800,7 +800,7 @@ def _gen_literal_list(items: list) -> str: result = [] for item in items: result.append(_gen_literal(item)) - return "{" + ",".join(result) + "}" + return "(" + ",".join(result) + ")" # Genearte a rel literal for the given string. @@ -832,7 +832,7 @@ def _gen_syntax_config(syntax: dict = {}) -> str: for k in _syntax_options: v = syntax.get(k, None) if v is not None: - result += f"def config:syntax:{k}={_gen_literal(v)}\n" + result += f"def config[:syntax, :{k}]: {_gen_literal(v)}\n" return result @@ -861,7 +861,7 @@ def load_csv( raise TypeError(f"bad type for arg 'data': {data.__class__.__name__}") inputs = {"data": data} command = _gen_syntax_config(syntax) - command += "def config:data = data\n" "def insert:%s = load_csv[config]" % relation + command += "def config[:data]: data\n" "def insert[:%s]: load_csv[config]" % relation return exec_v1(ctx, database, engine, command, inputs=inputs, readonly=False) @@ -879,7 +879,7 @@ def load_json( else: raise TypeError(f"bad type for arg 'data': {data.__class__.__name__}") inputs = {"data": data} - command = "def config:data = data\n" "def insert:%s = load_json[config]" % relation + command = "def config[:data]: data\n" "def insert[:%s]: load_json[config]" % relation return exec_v1(ctx, database, engine, command, inputs=inputs, readonly=False) diff --git a/relationalai-sdk-snowflake/test/test_integration.py b/relationalai-sdk-snowflake/test/test_integration.py index ae506c9..e12c411 100644 --- a/relationalai-sdk-snowflake/test/test_integration.py +++ b/relationalai-sdk-snowflake/test/test_integration.py @@ -208,7 +208,7 @@ def tearDownClass(cls): cls._session.close() def test_exec(self): - res = json.loads(api.exec(self._session, self._db_name, self._engine_name, "def output = 1 + 1").collect()[0][0]) + res = json.loads(api.exec(self._session, self._db_name, self._engine_name, "def output {1 + 1}").collect()[0][0]) self.assertEqual(res[0][0], 2) @@ -217,7 +217,7 @@ def test_exec_with_data(self): self._session, self._db_name, self._engine_name, - "def output = foo", + "def output { foo }", {"foo": "hello"} ).collect()[0][0] @@ -225,7 +225,7 @@ def test_exec_with_data(self): def test_exec_into(self): table_name = f"{FQ_SCHEMA}.test_exec_into_table" - res = api.exec_into(self._session, self._db_name, self._engine_name, "def output = 1 + 1", connection_parameters["warehouse"], table_name) + res = api.exec_into(self._session, self._db_name, self._engine_name, "def output {1 + 1}", connection_parameters["warehouse"], table_name) self.assertTrue(check_status_ok(res)) res = self._session.sql(f"select * from {table_name}").collect() @@ -237,7 +237,7 @@ def test_exec_into_with_data(self): self._session, self._db_name, self._engine_name, - "def output = foo", + "def output { foo }", connection_parameters["warehouse"], table_name, {"foo": "hello"} @@ -259,8 +259,8 @@ def setUp(self) -> None: api.create_engine(self.session, self.engine_name) def test_load_model_code(self): - res = api.load_model_code(self.session, self.db_name, self.engine_name, "my_model", "def mymax[x, y] = maximum[abs[x], abs[y]]") - res = json.loads(api.exec(self.session, self.db_name, self.engine_name, "def output = mymax[5, -10]").collect()[0][0]) + res = api.load_model_code(self.session, self.db_name, self.engine_name, "my_model", "def mymax[x, y]: maximum[abs[x], abs[y]]") + res = json.loads(api.exec(self.session, self.db_name, self.engine_name, "def output { mymax[5, -10] }").collect()[0][0]) self.assertEqual(res[0][0], 10) diff --git a/test/test_integration.py b/test/test_integration.py index 6a0270e..4eddb87 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -52,7 +52,7 @@ def setUp(self): self.assertEqual("CREATED", rsp["database"]["state"]) def test_v2_exec(self): - cmd = "x, x^2, x^3, x^4 from x in {1; 2; 3; 4; 5}" + cmd = "def output(x, x2, x3, x4): {1; 2; 3; 4; 5}(x) and x2 = x^2 and x3 = x^3 and x4 = x^4" rsp = api.exec(ctx, dbname, engine, cmd) # transaction