From 6f8f6253f8d577a0c6dcefa3e36711084313cef0 Mon Sep 17 00:00:00 2001 From: Jeffrey Aven Date: Wed, 4 Oct 2023 08:25:20 +1100 Subject: [PATCH] added issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++ .github/ISSUE_TEMPLATE/question.md | 15 ++++++++ .gitignore | 1 + extensions/stackql.py | 18 ++++++--- notebooks/aws/aws.ipynb | 45 +++++++++++++++++++++-- notebooks/github/github.ipynb | 9 +++-- 7 files changed, 133 insertions(+), 13 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/question.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..cb1b096 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '[BUG]' +labels: 'bug' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..c5b3a85 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE]" +labels: enhancement +assignees: '' + +--- + +**Feature Description** +A clear and concise description of what you want to happen. + +**Example(s)** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Possible Approaches or Libraries to Consider** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/question.md b/.github/ISSUE_TEMPLATE/question.md new file mode 100644 index 0000000..5a55f41 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/question.md @@ -0,0 +1,15 @@ +--- +name: Question +about: Pose a question to the StackQL team +title: "[QUESTION]" +labels: question +assignees: '' + +--- + + +## Question + +This channel is an opportunity to ask ad-hoc questions to the `stackql` team. This channel is in lieu of an official platform for ongoing discussions and questions. Please ask your question :) + +**Note**: Questions over github issues will be deprecated and retired once we settle on a platform / process ongoing. \ No newline at end of file diff --git a/.gitignore b/.gitignore index fa67296..6213941 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ apikeys.sh apikeys.ps1 stackql stackql-zip +test.py \ No newline at end of file diff --git a/extensions/stackql.py b/extensions/stackql.py index d9a173b..f4a2a3e 100644 --- a/extensions/stackql.py +++ b/extensions/stackql.py @@ -18,12 +18,18 @@ def get_rendered_query(self, data): return rendered def run_query(self, query): - cur = conn.cursor(cursor_factory=RealDictCursor) - cur.execute(query) - rows = cur.fetchall() - cur.close() - json_str = json.dumps(rows) - return pd.read_json(StringIO(json_str)) + try: + cur = conn.cursor(cursor_factory=RealDictCursor) + cur.execute(query) + rows = cur.fetchall() + cur.close() + json_str = json.dumps(rows) + return pd.read_json(StringIO(json_str)) + except psycopg2.ProgrammingError as e: + if str(e) == "no results to fetch": + return [] + else: + raise @line_cell_magic def stackql(self, line, cell=None): diff --git a/notebooks/aws/aws.ipynb b/notebooks/aws/aws.ipynb index e8c017a..c3e84db 100644 --- a/notebooks/aws/aws.ipynb +++ b/notebooks/aws/aws.ipynb @@ -6,7 +6,10 @@ "metadata": {}, "outputs": [], "source": [ - "%load_ext ext.stackql" + "import sys\n", + "sys.path.append('/jupyter/ext')\n", + "import stackql\n", + "%load_ext stackql" ] }, { @@ -64,6 +67,43 @@ "_.plot(kind='pie', y='num_instances', labels=_['instanceType'], title='Instances by Type', autopct='%1.1f%%')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%%stackql\n", + "CREATE MATERIALIZED VIEW vw_ec2_instance_types AS\n", + "SELECT \n", + "memoryInfo,\n", + "hypervisor,\n", + "autoRecoverySupported,\n", + "instanceType,\n", + "SPLIT_PART(processorInfo, '\\n', 3) as processorArch,\n", + "currentGeneration,\n", + "freeTierEligible,\n", + "hibernationSupported,\n", + "SPLIT_PART(vCpuInfo, '\\n', 2) as vCPUs,\n", + "bareMetal,\n", + "burstablePerformanceSupported,\n", + "dedicatedHostsSupported\n", + "FROM aws.ec2.instance_types\n", + "WHERE region = '$region'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# get multiple regions asynchronously\n", + "from pystackql import StackQL\n", + "stackql = StackQL()\n", + "stackql.executeStmt(\"REGISTRY PULL aws\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -73,11 +113,8 @@ "# get multiple regions asynchronously\n", "import nest_asyncio, json\n", "nest_asyncio.apply()\n", - "from pystackql import StackQL\n", "import pandas as pd\n", "\n", - "stackql = StackQL()\n", - "\n", "regions = [\"ap-southeast-2\", \"us-east-1\"]\n", "\n", "queries = [\n", diff --git a/notebooks/github/github.ipynb b/notebooks/github/github.ipynb index 98a3805..40177bf 100644 --- a/notebooks/github/github.ipynb +++ b/notebooks/github/github.ipynb @@ -6,7 +6,10 @@ "metadata": {}, "outputs": [], "source": [ - "%load_ext ext.stackql" + "import sys\n", + "sys.path.append('/jupyter/ext')\n", + "import stackql\n", + "%load_ext stackql" ] }, { @@ -27,7 +30,7 @@ "%%stackql\n", "SELECT *\n", "FROM github.repos.contributors\n", - "where repo = 'stackql-playground' AND owner = '$owner'" + "where repo = 'stackql' AND owner = '$owner'" ] }, { @@ -49,7 +52,7 @@ "metadata": {}, "outputs": [], "source": [ - "_.plot(kind='bar', title='Commit History', x='commit_date', y='num_commits')" + "stackql_df.plot(kind='line', title='Commit History', x='commit_date', y='num_commits')" ] } ],