This is an automated email from the ASF dual-hosted git repository.

dimuthuupe pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/master by this push:
     new 657897d2b4 Initial magic extension bundle
657897d2b4 is described below

commit 657897d2b4b14d4c98e9bddea7e9734dfd04c0d2
Author: Dimuthu Wannipurage <[email protected]>
AuthorDate: Thu Jul 18 07:12:03 2024 -0400

    Initial magic extension bundle
---
 modules/agent-framework/airavata-agent/agent.go    |   4 +-
 .../airavata-agent/jupyter/README.md               |  28 ++-
 .../extension/airavata_jupyter_magic/LICENSE       | 202 +++++++++++++++++
 .../extension/airavata_jupyter_magic/README.md     |  33 +++
 .../airavata_jupyter_magic/__init__.py             |   1 +
 .../airavata_jupyter_magic.py                      |  50 +++++
 .../build/lib/airavata_jupyter_magic/__init__.py   |   1 +
 .../airavata_magic_extension.py                    |  47 ++++
 .../extension/airavata_jupyter_magic/setup.py      |  23 ++
 .../airavata-agent/jupyter/magic.ipynb             | 249 +++++++++++++++++++++
 10 files changed, 635 insertions(+), 3 deletions(-)

diff --git a/modules/agent-framework/airavata-agent/agent.go 
b/modules/agent-framework/airavata-agent/agent.go
index b2e82c1f40..b2e7a2a80c 100644
--- a/modules/agent-framework/airavata-agent/agent.go
+++ b/modules/agent-framework/airavata-agent/agent.go
@@ -144,9 +144,9 @@ func main() {
                                                log.Printf("Failed to read 
response for run jupyter kernel: %v", err)
                                        }
 
-                                       log.Println("Jupyter execution 
response")
+                                       
                                        jupyterResponse := string(body)
-
+                                       log.Println("Jupyter execution 
response: " + jupyterResponse)
 
                                        if err := 
stream.Send(&protos.AgentMessage{Message: 
                                                
&protos.AgentMessage_JupyterExecutionResponse{
diff --git a/modules/agent-framework/airavata-agent/jupyter/README.md 
b/modules/agent-framework/airavata-agent/jupyter/README.md
index 3f012526e8..565673eadc 100644
--- a/modules/agent-framework/airavata-agent/jupyter/README.md
+++ b/modules/agent-framework/airavata-agent/jupyter/README.md
@@ -15,4 +15,30 @@ python3 kernel.py
 curl -X GET  http://127.0.0.1:15000/start
 curl -X POST http://127.0.0.1:15000/execute -H "Content-Type: 
application/json" -d '{"code": "print(4)"}'
 curl -X GET  http://127.0.0.1:15000/stop
-```
\ No newline at end of file
+```
+
+
+### Build and upload the magic extension
+
+* Make sure you have `setuptools` and `wheel` installed:
+
+```
+pip install setuptools wheel
+```
+
+* Build the extension
+```
+cd jupyter/extension/airavata_jupyter_magic
+python setup.py sdist bdist_wheel
+```
+
+* Upload the distribution to pypi
+```
+pip install twine
+twine upload dist/*
+```
+
+* Extension is available at https://pypi.org/project/airavata-jupyter-magic
+
+
+
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/LICENSE
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/LICENSE
new file mode 100644
index 0000000000..d645695673
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/LICENSE
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/README.md
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/README.md
new file mode 100644
index 0000000000..e903231f7d
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/README.md
@@ -0,0 +1,33 @@
+# Airavata Magic Extension to run local Jupyter Notebooks on Clusters
+
+
+## Installation
+
+```
+pip install airavata_jupyter_magic
+```
+
+## Usage
+
+### Load the extension in the notebook
+```
+%load_ext airavata_jupyter_magic
+```
+
+### Initialize the remote cluster job
+```
+%init_remote cluster=jetstream cpu=2 memory=2GB
+```
+
+### Run remote cell
+```
+%%run_remote
+# Your code here
+a = 10 + a
+print(a)
+```
+
+### Terminate the remote cluster job and the connection
+```
+%terminate_remote
+```
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/airavata_jupyter_magic/__init__.py
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/airavata_jupyter_magic/__init__.py
new file mode 100644
index 0000000000..174863c815
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/airavata_jupyter_magic/__init__.py
@@ -0,0 +1 @@
+from .airavata_jupyter_magic import load_ipython_extension, 
unload_ipython_extension
\ No newline at end of file
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/airavata_jupyter_magic/airavata_jupyter_magic.py
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/airavata_jupyter_magic/airavata_jupyter_magic.py
new file mode 100644
index 0000000000..1d30e9781b
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/airavata_jupyter_magic/airavata_jupyter_magic.py
@@ -0,0 +1,50 @@
+from IPython.core.magic import register_line_magic, register_cell_magic
+
+def load_ipython_extension(ipython):
+    
+    @register_cell_magic
+    def run_remote(line, cell):
+        url = 'http://localhost:18880/api/v1/agent/executejupyterrequest'
+
+        data = {
+            "sessionId": "session1",
+            "keepAlive": True,
+            "code": cell,
+            "agentId": "agent3"
+        }
+
+        json_data = json.dumps(data)    
+        response = requests.post(url, headers={'Content-Type': 
'application/json'}, data=json_data)
+        execution_resp = response.json()
+        execution_id = execution_resp["executionId"]
+        error = execution_resp["error"]
+        if error:
+            print("Cell execution failed. Error: " + error)
+        if execution_id:
+            while True:
+                url = 
"http://localhost:18880/api/v1/agent/executejupyterresponse/"; + execution_id
+                response = requests.get(url, headers={'Accept': 
'application/json'})
+                json_response = response.json()
+                #print(json_response)
+                if json_response['available']:
+                    result_str = json_response['responseString']
+                    result = json.loads(result_str)
+                    if 'result' in result:
+                        print(result['result'])
+                    elif 'error' in result:
+                        print(result['error']['ename'])
+                        print(result['error']['evalue'])
+                        print(result['error']['traceback'])
+                    break
+                time.sleep(1)
+
+    @register_line_magic
+    def init_remote(line):
+        print(f"Your input: {line}")
+
+    @register_line_magic
+    def terminate_remote(line):
+        print(f"Your input: {line}")
+
+def unload_ipython_extension(ipython):
+    pass
\ No newline at end of file
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/build/lib/airavata_jupyter_magic/__init__.py
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/build/lib/airavata_jupyter_magic/__init__.py
new file mode 100644
index 0000000000..174863c815
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/build/lib/airavata_jupyter_magic/__init__.py
@@ -0,0 +1 @@
+from .airavata_jupyter_magic import load_ipython_extension, 
unload_ipython_extension
\ No newline at end of file
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/build/lib/airavata_jupyter_magic/airavata_magic_extension.py
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/build/lib/airavata_jupyter_magic/airavata_magic_extension.py
new file mode 100644
index 0000000000..59beeabb6e
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/build/lib/airavata_jupyter_magic/airavata_magic_extension.py
@@ -0,0 +1,47 @@
+from IPython.core.magic import register_line_magic, register_cell_magic
+
+def load_ipython_extension(ipython):
+    
+    @register_cell_magic
+    def run_remote(line, cell):
+        url = 'http://localhost:18880/api/v1/agent/executejupyterrequest'
+
+        data = {
+            "sessionId": "session1",
+            "keepAlive": True,
+            "code": cell,
+            "agentId": "agent3"
+        }
+
+        json_data = json.dumps(data)    
+        response = requests.post(url, headers={'Content-Type': 
'application/json'}, data=json_data)
+        execution_resp = response.json()
+        execution_id = execution_resp["executionId"]
+        error = execution_resp["error"]
+        if error:
+            print("Cell execution failed. Error: " + error)
+        if execution_id:
+            while True:
+                url = 
"http://localhost:18880/api/v1/agent/executejupyterresponse/"; + execution_id
+                response = requests.get(url, headers={'Accept': 
'application/json'})
+                json_response = response.json()
+                #print(json_response)
+                if json_response['available']:
+                    result_str = json_response['responseString']
+                    result = json.loads(result_str)
+                    if 'result' in result:
+                        print(result['result'])
+                    elif 'error' in result:
+                        print(result['error']['ename'])
+                        print(result['error']['evalue'])
+                        print(result['error']['traceback'])
+                    break
+                time.sleep(1)
+
+    @register_line_magic
+    def init_remote(line):
+        print(f"Your input: {line}")
+
+    @register_line_magic
+    def terminate_remote(line):
+        print(f"Your input: {line}")
\ No newline at end of file
diff --git 
a/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/setup.py
 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/setup.py
new file mode 100644
index 0000000000..7cbcf810b8
--- /dev/null
+++ 
b/modules/agent-framework/airavata-agent/jupyter/extension/airavata_jupyter_magic/setup.py
@@ -0,0 +1,23 @@
+from setuptools import setup, find_packages
+
+setup(
+    name='airavata_jupyter_magic',
+    version='0.5',
+    packages=find_packages(),
+    install_requires=[
+        # Add any dependencies your extension needs here
+    ],
+    include_package_data=True,
+    description='A custom IPython magic extension for Airavata to recute local 
notebooks on clusters',
+    long_description=open('README.md').read(),
+    long_description_content_type='text/markdown',
+    author='Dimuthu Wannipurage',
+    author_email='[email protected]',
+    url='https://github.com/apache/airavata',  # Update with your repo link
+    classifiers=[
+        'Programming Language :: Python :: 3',
+        'License :: OSI Approved :: Apache Software License',
+        'Operating System :: OS Independent',
+    ],
+    license='Apache License 2.0',
+)
\ No newline at end of file
diff --git a/modules/agent-framework/airavata-agent/jupyter/magic.ipynb 
b/modules/agent-framework/airavata-agent/jupyter/magic.ipynb
new file mode 100644
index 0000000000..5f80e5782c
--- /dev/null
+++ b/modules/agent-framework/airavata-agent/jupyter/magic.ipynb
@@ -0,0 +1,249 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 40,
+   "id": "e520a5ea-847a-4237-a0a8-e52deb0b2c0d",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from IPython.core.magic import register_cell_magic\n",
+    "from IPython.core.magic import register_line_magic\n",
+    "\n",
+    "import time\n",
+    "import requests\n",
+    "import json\n",
+    "import time"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 41,
+   "id": "c5c591cb-7f0f-47ab-a9fa-4700161439c2",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "@register_cell_magic\n",
+    "def run_remote(line, cell):\n",
+    "    url = 'http://localhost:18880/api/v1/agent/executejupyterrequest'\n",
+    "\n",
+    "    data = {\n",
+    "        \"sessionId\": \"session1\",\n",
+    "        \"keepAlive\": True,\n",
+    "        \"code\": cell,\n",
+    "        \"agentId\": \"agent3\"\n",
+    "    }\n",
+    "\n",
+    "    json_data = json.dumps(data)    \n",
+    "    response = requests.post(url, headers={'Content-Type': 
'application/json'}, data=json_data)\n",
+    "    execution_resp = response.json()\n",
+    "    execution_id = execution_resp[\"executionId\"]\n",
+    "    error = execution_resp[\"error\"]\n",
+    "    if error:\n",
+    "        print(\"Cell execution failed. Error: \" + error)\n",
+    "    if execution_id:\n",
+    "        while True:\n",
+    "            url = 
\"http://localhost:18880/api/v1/agent/executejupyterresponse/\"; + 
execution_id\n",
+    "            response = requests.get(url, headers={'Accept': 
'application/json'})\n",
+    "            json_response = response.json()\n",
+    "            #print(json_response)\n",
+    "            if json_response['available']:\n",
+    "                result_str = json_response['responseString']\n",
+    "                result = json.loads(result_str)\n",
+    "                if 'result' in result:\n",
+    "                    print(result['result'])\n",
+    "                elif 'error' in result:\n",
+    "                    print(result['error']['ename'])\n",
+    "                    print(result['error']['evalue'])\n",
+    "                    print(result['error']['traceback'])\n",
+    "                break\n",
+    "            time.sleep(1)\n",
+    "\n",
+    "@register_line_magic\n",
+    "def init_remote(line):\n",
+    "    print(f\"Your input: {line}\")\n",
+    "\n",
+    "@register_line_magic\n",
+    "def terminate_remote(line):\n",
+    "    print(f\"Your input: {line}\")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "id": "5c43ee08-39fc-4e44-a3f6-9f7ba372d201",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Collecting airavata-jupyter-magic==0.5\n",
+      "  Obtaining dependency information for airavata-jupyter-magic==0.5 from 
https://files.pythonhosted.org/packages/12/1b/f7214be1a74520d1af8f7810ade38b0346f74b8ccf998eb0586a77b4e636/airavata_jupyter_magic-0.5-py3-none-any.whl.metadata\n";,
+      "  Downloading airavata_jupyter_magic-0.5-py3-none-any.whl.metadata (994 
bytes)\n",
+      "Downloading airavata_jupyter_magic-0.5-py3-none-any.whl (7.6 kB)\n",
+      "Installing collected packages: airavata-jupyter-magic\n",
+      "  Attempting uninstall: airavata-jupyter-magic\n",
+      "    Found existing installation: airavata-jupyter-magic 0.4\n",
+      "    Uninstalling airavata-jupyter-magic-0.4:\n",
+      "      Successfully uninstalled airavata-jupyter-magic-0.4\n",
+      "Successfully installed airavata-jupyter-magic-0.5\n",
+      "\n",
+      
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m
 A new release of pip is available: 
\u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> 
\u001b[0m\u001b[32;49m24.1.2\u001b[0m\n",
+      
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m
 To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n"
+     ]
+    }
+   ],
+   "source": [
+    "! pip install airavata-jupyter-magic==0.5"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "id": "4c04f9ef-161c-4eb5-bd60-78a68ef614ac",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "The airavata_jupyter_magic module is not an IPython extension.\n"
+     ]
+    }
+   ],
+   "source": [
+    "%load_ext airavata_jupyter_magic"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "9e969c05-fbf9-4eca-9b83-d1c62429a13b",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "UsageError: Line magic function `%init_remote` not found.\n"
+     ]
+    }
+   ],
+   "source": [
+    "%init_remote cluster=jetstream cpu=2 memory=2GB"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 48,
+   "id": "4e60d84a-2a81-4b04-9dcb-dea48c4228b8",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "70\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "%%run_remote\n",
+    "# Your code here\n",
+    "a = 10 + a\n",
+    "print(a)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 35,
+   "id": "ebd549f1-3a5d-47e3-876d-beb91d971ac2",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "%%run_remote\n",
+    "b = 20"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "id": "01b350f1-dc56-4434-86c1-0ff024cc589d",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Requirement already satisfied: numpy in 
./jupyter/venv/lib/python3.11/site-packages (2.0.0)\n",
+      "\n",
+      
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m
 A new release of pip is available: 
\u001b[0m\u001b[31;49m23.2.1\u001b[0m\u001b[39;49m -> 
\u001b[0m\u001b[32;49m24.1.2\u001b[0m\n",
+      
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m
 To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "%%run_remote cluster=jetstream cpu=2 memory=2GB\n",
+    "!pip install numpy"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 43,
+   "id": "4acff051-2148-45d6-bb4e-c3cabb1a162c",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Your input: \n"
+     ]
+    }
+   ],
+   "source": [
+    "%terminate_remote"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "ad0cb710-d4f7-490e-a7b6-a8d97a3f45ed",
+   "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.11.5"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

Reply via email to