Skip to content

Commit fe6f718

Browse files
committed
updated statement output behaviour
1 parent 24eccf6 commit fe6f718

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Changelog
22

3-
## v3.2.3 (2023-10-20)
3+
## v3.2.4 (2023-10-24)
44

55
### Updates
66

77
* implemented non `server_mode` magic extension
8+
* updated dataframe output for statements
89
* `pandas` type updates
910
* updated class parameters
1011
* added additional tests

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,4 @@ To publish the package to PyPI, run the following command:
193193

194194
::
195195

196-
twine upload dist/pystackql-3.2.3.tar.gz
196+
twine upload dist/pystackql-3.2.4.tar.gz

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = ''
2828
# The full version, including alpha/beta/rc tags
29-
release = '3.2.3'
29+
release = '3.2.4'
3030

3131

3232
# -- General configuration ---------------------------------------------------

pystackql/stackql.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ def upgrade(self, showprogress=True):
393393
def executeStmt(self, query):
394394
"""Executes a query using the StackQL instance and returns the output as a string.
395395
This is intended for operations which do not return a result set, for example a mutation
396-
operation such as an `INSERT` or a `DELETE` or life cycle method such as an `EXEC` operation.
396+
operation such as an `INSERT` or a `DELETE` or life cycle method such as an `EXEC` operation
397+
or a `REGISTRY PULL` operation.
397398
398399
This method determines the mode of operation (server_mode or local execution) based
399400
on the `server_mode` attribute of the instance. If `server_mode` is True, it runs the query
@@ -404,7 +405,7 @@ def executeStmt(self, query):
404405
405406
:return: The output result of the query in string format. If in `server_mode`, it
406407
returns a JSON string representation of the result.
407-
:rtype: str
408+
:rtype: dict, Pandas DataFrame or str (for `csv` output)
408409
409410
Example:
410411
>>> from pystackql import StackQL

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
setup(
1212
name='pystackql',
13-
version='3.2.3',
13+
version='3.2.4',
1414
description='A Python interface for StackQL',
1515
long_description=readme,
1616
author='Jeffrey Aven',

tests/pystackql_tests.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import sys, os, unittest, asyncio
1+
import sys, os, unittest, asyncio, re
22
from unittest.mock import MagicMock
33
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
44
from pystackql import StackQL, magic, magics, StackqlMagic, StackqlServerMagic
@@ -354,23 +354,36 @@ def run_magic_statement_test(self, line, cell, expect_none=False):
354354
# Validate the outcome.
355355
checks = []
356356
# Check that the output contains expected content
357-
if not expect_none:
358-
checks.append("OK" in result["message"].iloc[0])
357+
if expect_none:
358+
checks.append(result is None)
359+
else:
360+
if self.server_mode:
361+
checks.append("OK" in result["message"].iloc[0])
362+
else:
363+
pattern = registry_pull_resp_pattern('github')
364+
message = result["message"].iloc[0] if "message" in result.columns else ""
365+
checks.append(bool(re.search(pattern, message)))
366+
# Check dataframe exists and is populated as expected
359367
checks.append('stackql_df' in self.shell.user_ns)
360-
checks.append("OK" in self.shell.user_ns['stackql_df']["message"].iloc[0])
361-
return checks
368+
if self.server_mode:
369+
checks.append("OK" in self.shell.user_ns['stackql_df']["message"].iloc[0])
370+
else:
371+
pattern = registry_pull_resp_pattern('github')
372+
message = self.shell.user_ns['stackql_df']["message"].iloc[0] if 'stackql_df' in self.shell.user_ns else ""
373+
checks.append(bool(re.search(pattern, message)))
374+
return checks, result
362375

363376
def test_line_magic_statement(self):
364-
checks = self.run_magic_statement_test(line=self.statement, cell=None)
365-
self.print_test_result(f"Line magic statement test\n{str(checks)}", *checks)
377+
checks, result = self.run_magic_statement_test(line=self.statement, cell=None)
378+
self.print_test_result(f"Line magic statement test\n{result}", *checks)
366379

367380
def test_cell_magic_statement(self):
368-
checks = self.run_magic_statement_test(line="", cell=self.statement)
369-
self.print_test_result(f"Cell magic statement test\n{str(checks)}", *checks)
381+
checks, result = self.run_magic_statement_test(line="", cell=self.statement)
382+
self.print_test_result(f"Cell magic statement test\n{result}", *checks)
370383

371384
def test_cell_magic_statement_no_output(self):
372-
checks = self.run_magic_statement_test(line="--no-display", cell=self.statement, expect_none=True)
373-
self.print_test_result(f"Cell magic statement test (with --no-display)\n{str(checks)}", *checks)
385+
checks, result = self.run_magic_statement_test(line="--no-display", cell=self.statement, expect_none=True)
386+
self.print_test_result(f"Cell magic statement test (with --no-display)\n{result}", *checks)
374387

375388
class StackQLMagicTests(BaseStackQLMagicTests, unittest.TestCase):
376389

0 commit comments

Comments
 (0)