diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1b09024..edadbc0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,26 +13,12 @@ jobs: node-version: "16" - name: Install dependencies run: npm install - - name: Install python - uses: actions/setup-python@v3 - with: - python-version: "3.x" - - run: pip install jupyterlab jupyter-packaging jupyterlite[all] - name: Linting and type checking run: npm run lint - name: Tests run: npm run test - name: Build project run: npm run build - - run: | - pip install apps/jupyter - mkdir jupyterlite - cd jupyterlite - jupyter lite init - mkdir files - cp ../apps/jupyter/Example.ipynb files/ - jupyter lite build - cd .. - name: Upload ftp if: github.ref == 'refs/heads/main' uses: sebastianpopp/ftp-action@releases/v2 @@ -43,13 +29,3 @@ jobs: localDir: "apps/example/dist" remoteDir: "/" forceSsl: true - - name: Upload Jupyterlite - if: github.ref == 'refs/heads/main' - uses: sebastianpopp/ftp-action@releases/v2 - with: - host: niklaskorz.lima-ftp.de - user: ${{ secrets.FTP_USER }} - password: ${{ secrets.FTP_PASSWORD }} - localDir: "jupyterlite/_output" - remoteDir: "/jupyter" - forceSsl: true diff --git a/apps/jupyter/Example.ipynb b/apps/jupyter/Example.ipynb deleted file mode 100644 index ae90189..0000000 --- a/apps/jupyter/Example.ipynb +++ /dev/null @@ -1,116 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 17, - "id": "d2b74a6c-2105-45ef-a784-edf5d69ae790", - "metadata": {}, - "outputs": [], - "source": [ - "class Column(object):\n", - " def __init__(self, tableName, columnName):\n", - " self.tableName = tableName\n", - " self.columnName = columnName\n", - "\n", - " def replace(self, target, replacement):\n", - " print(f\"REPLACE {target} IN {self.tableName}.{self.columnName} WITH {replacement}\")\n", - "\n", - " def trim(self, direction):\n", - " print(f\"TRIM {self.tableName}.{self.columnName} ON {direction}\")\n", - "\n", - "class Table(object):\n", - " def __init__(self, tableName):\n", - " self.tableName = tableName\n", - "\n", - " def column(self, columnName):\n", - " return Column(self.tableName, columnName)\n", - "\n", - "class ChangeBlock(object):\n", - " def __init__(self, tableName):\n", - " self.tableName = tableName\n", - "\n", - " def __enter__(self):\n", - " return Table(self.tableName)\n", - "\n", - " def __exit__(self, *args):\n", - " pass\n", - "\n", - "class Database(object):\n", - " def __init__(self):\n", - " pass\n", - "\n", - " def change(self, tableName):\n", - " return ChangeBlock(tableName)\n", - "\n", - "db = Database()" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "8f62bcd3-11f1-4e78-9c9e-355647fcbb20", - "metadata": { - "tags": [] - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "REPLACE Mister IN students.firstName WITH Mr.\n", - "TRIM students.secondName ON right\n" - ] - } - ], - "source": [ - "def x(input, name):\n", - " print(\"Hello world!\")\n", - " if True:\n", - " while 2 < 1:\n", - " with db.change(\"lectures\") as table:\n", - " table.column(\"lecturer\").replace(\"\", \"\")\n", - " table.column(\"name\").trim(\"both\")\n", - "\n", - "\n", - "with db.change(\"students\") as table:\n", - " table.column(\"firstName\").replace(\"Mister\", \"Mr.\")\n", - " table.column(\"secondName\").trim(\"right\")\n", - "\n", - "y = 42\n", - "y + 10\n", - "\n", - "if y > 42:\n", - " x = 3\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cdffe7fd-0366-4f81-ade3-d111be16c0b8", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.2" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/apps/jupyter/example/Example.ipynb b/apps/jupyter/example/Example.ipynb new file mode 100644 index 0000000..83d0693 --- /dev/null +++ b/apps/jupyter/example/Example.ipynb @@ -0,0 +1,73 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "8f62bcd3-11f1-4e78-9c9e-355647fcbb20", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "UPDATE students SET firstName = REPLACE(firstName, 'Mister', 'Mr.')\n", + "UPDATE students SET secondName = RTRIM(students)\n" + ] + } + ], + "source": [ + "from dsl import db\n", + "\n", + "def x(input, name):\n", + " print(\"Hello world!\")\n", + " if True:\n", + " while 2 < 1:\n", + " with db.change(\"lectures\") as table:\n", + " table.column(\"lecturer\").replace(\"\", \"\")\n", + " table.column(\"name\").trim(\"both\")\n", + "\n", + "\n", + "with db.change(\"students\") as table:\n", + " table.column(\"firstName\").replace(\"Mister\", \"Mr.\")\n", + " table.column(\"secondName\").trim(\"right\")\n", + "\n", + "y = 42\n", + "y + 10\n", + "\n", + "if y > 42:\n", + " x = 3\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cdffe7fd-0366-4f81-ade3-d111be16c0b8", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.10" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/apps/jupyter/example/dsl.py b/apps/jupyter/example/dsl.py new file mode 100644 index 0000000..ebfd072 --- /dev/null +++ b/apps/jupyter/example/dsl.py @@ -0,0 +1,41 @@ +class Column(object): + def __init__(self, tableName, columnName): + self.tableName = tableName + self.columnName = columnName + + def replace(self, target, replacement): + print(f"UPDATE {self.tableName} SET {self.columnName} = REPLACE({self.columnName}, {repr(target)}, {repr(replacement)})") + + def trim(self, direction): + command = "TRIM" + if direction == "left": + command = "LTRIM" + elif direction == "right": + command = "RTRIM" + print(f"UPDATE {self.tableName} SET {self.columnName} = {command}({self.tableName})") + +class Table(object): + def __init__(self, tableName): + self.tableName = tableName + + def column(self, columnName): + return Column(self.tableName, columnName) + +class ChangeBlock(object): + def __init__(self, tableName): + self.tableName = tableName + + def __enter__(self): + return Table(self.tableName) + + def __exit__(self, *args): + pass + +class Database(object): + def __init__(self): + pass + + def change(self, tableName): + return ChangeBlock(tableName) + +db = Database() diff --git a/apps/jupyter/package.json b/apps/jupyter/package.json index 43d834d..3e2fd2e 100644 --- a/apps/jupyter/package.json +++ b/apps/jupyter/package.json @@ -28,7 +28,7 @@ "url": "https://github.com/niklaskorz/puredit.git" }, "scripts": { - "build": "npm run clean && npm run build:labextension", + "build:prod": "npm run clean && npm run build:labextension", "build:dev": "npm run build:labextension:dev", "build:labextension": "NODE_ENV=production jupyter labextension build .", "build:labextension:dev": "jupyter labextension build --development True .",