hpc-interact


Namehpc-interact JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/enviro-lab/hpc-interact.git
SummaryUsed for file transfer and sending predefined commands to an hpc cluster
upload_time2023-03-17 21:20:26
maintainer
docs_urlNone
authorSam Kunkleman
requires_python>=3.8,<4.0
licenseMIT
keywords upload download sftp ssh expect file transfer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # hpc-interact
Used for scripting file transfer (sftp) and sending commands (ssh) to hpc - a wrapper for `expect`

## Requires `expect`
If needed, install via:
```
$ sudo apt install expect
```

## Install
From PyPI:
```console
pip install hpc-interact
```

Or just clone the repo and use `hpc_interact.py` directly.

## Usage
Instantiate a Scripter object:
```python
>>> # Connect via sftp
>>> from hpc_interact import Scripter
>>> scripter = Scripter(config="./login_config", site='somewhere.uni.edu', mode='sftp')
>>> # NOTE: If "./login_config" doesn't exist, you'll be prompted to create it
```

Prepare any steps to undertake
```python
>>> outdir = "/Users/me/somedir"
>>> scripter.cwd("/some/remote/directory")
>>> for file in ["file1.txt","file2.txt"]:
...     scripter.get(file,outdir)
```

### To see what steps you've added, run:
```
>>> scripter.preview_steps()
```
Output:
```console

Command preview:
(0, 'cd /some/remote/directory\n')
(1, 'mkdir /Users/me/somedir\n')
(2, 'cd /Users/me/somedir\n')
(3, 'put file1.txt \n\n')
(4, 'mkdir /Users/me/somedir\n')
(5, 'cd /Users/me/somedir\n')
(6, 'put file2.txt \n\n')
```

### To run:
```python
>>> scripter.run()
```

### Forgot something but don't want to create a new Scripter object?
```python
>>> scripter.clear()
>>> scripter.put("/Users/me/another-dir/cool_script.sh",outdir="/some/remote/directory",new_name="coolest_script_on_the_hpc.sh")
>>> scripter.run()
```

### Run a script on the cluster
```python
>>> # Connect via ssh
>>> from hpc_interact import cluster.Scripter
>>> scripter = Scripter(config="./login_config", site='somewhere.uni.edu', mode='ssh')
>>> 
>>> # run it
>>> scripter.basic_step("bash","/some/remote/directory/coolest_script_on_the_hpc.sh")
>>> scripter.run()
```

### Started as ssh but want need to transfer files?
```python
>>> scripter.reset_mode("sftp")
>>> add_some_steps(scripter)
>>> scripter.run()
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/enviro-lab/hpc-interact.git",
    "name": "hpc-interact",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "upload,download,sftp,ssh,expect,file transfer",
    "author": "Sam Kunkleman",
    "author_email": "skunklem@uncc.edu",
    "download_url": "https://files.pythonhosted.org/packages/91/09/9c224ae40f5f541b2ecf2bddc9337f96957e4ab4aecf49ef92071035684d/hpc_interact-0.1.1.tar.gz",
    "platform": null,
    "description": "# hpc-interact\nUsed for scripting file transfer (sftp) and sending commands (ssh) to hpc - a wrapper for `expect`\n\n## Requires `expect`\nIf needed, install via:\n```\n$ sudo apt install expect\n```\n\n## Install\nFrom PyPI:\n```console\npip install hpc-interact\n```\n\nOr just clone the repo and use `hpc_interact.py` directly.\n\n## Usage\nInstantiate a Scripter object:\n```python\n>>> # Connect via sftp\n>>> from hpc_interact import Scripter\n>>> scripter = Scripter(config=\"./login_config\", site='somewhere.uni.edu', mode='sftp')\n>>> # NOTE: If \"./login_config\" doesn't exist, you'll be prompted to create it\n```\n\nPrepare any steps to undertake\n```python\n>>> outdir = \"/Users/me/somedir\"\n>>> scripter.cwd(\"/some/remote/directory\")\n>>> for file in [\"file1.txt\",\"file2.txt\"]:\n...     scripter.get(file,outdir)\n```\n\n### To see what steps you've added, run:\n```\n>>> scripter.preview_steps()\n```\nOutput:\n```console\n\nCommand preview:\n(0, 'cd /some/remote/directory\\n')\n(1, 'mkdir /Users/me/somedir\\n')\n(2, 'cd /Users/me/somedir\\n')\n(3, 'put file1.txt \\n\\n')\n(4, 'mkdir /Users/me/somedir\\n')\n(5, 'cd /Users/me/somedir\\n')\n(6, 'put file2.txt \\n\\n')\n```\n\n### To run:\n```python\n>>> scripter.run()\n```\n\n### Forgot something but don't want to create a new Scripter object?\n```python\n>>> scripter.clear()\n>>> scripter.put(\"/Users/me/another-dir/cool_script.sh\",outdir=\"/some/remote/directory\",new_name=\"coolest_script_on_the_hpc.sh\")\n>>> scripter.run()\n```\n\n### Run a script on the cluster\n```python\n>>> # Connect via ssh\n>>> from hpc_interact import cluster.Scripter\n>>> scripter = Scripter(config=\"./login_config\", site='somewhere.uni.edu', mode='ssh')\n>>> \n>>> # run it\n>>> scripter.basic_step(\"bash\",\"/some/remote/directory/coolest_script_on_the_hpc.sh\")\n>>> scripter.run()\n```\n\n### Started as ssh but want need to transfer files?\n```python\n>>> scripter.reset_mode(\"sftp\")\n>>> add_some_steps(scripter)\n>>> scripter.run()\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Used for file transfer and sending predefined commands to an hpc cluster",
    "version": "0.1.1",
    "split_keywords": [
        "upload",
        "download",
        "sftp",
        "ssh",
        "expect",
        "file transfer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "aa095c483d4accc32cccddf521ae05a8a08fda4329909ab612e85211dd95b355",
                "md5": "847087239e19f350054ffaa45ba67c0c",
                "sha256": "87143a371871fb31259527474e6c6eb3b2669b86df2882733f29aeacaa927522"
            },
            "downloads": -1,
            "filename": "hpc_interact-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "847087239e19f350054ffaa45ba67c0c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 8806,
            "upload_time": "2023-03-17T21:20:24",
            "upload_time_iso_8601": "2023-03-17T21:20:24.758752Z",
            "url": "https://files.pythonhosted.org/packages/aa/09/5c483d4accc32cccddf521ae05a8a08fda4329909ab612e85211dd95b355/hpc_interact-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "91099c224ae40f5f541b2ecf2bddc9337f96957e4ab4aecf49ef92071035684d",
                "md5": "24734e4704a08c5e1deca3d9552990f2",
                "sha256": "c9f20161d826badb0f59b8517412d851cc0432b687f03066eab88f75bf6e9dab"
            },
            "downloads": -1,
            "filename": "hpc_interact-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "24734e4704a08c5e1deca3d9552990f2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 8139,
            "upload_time": "2023-03-17T21:20:26",
            "upload_time_iso_8601": "2023-03-17T21:20:26.830105Z",
            "url": "https://files.pythonhosted.org/packages/91/09/9c224ae40f5f541b2ecf2bddc9337f96957e4ab4aecf49ef92071035684d/hpc_interact-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-17 21:20:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "enviro-lab",
    "github_project": "hpc-interact.git",
    "lcname": "hpc-interact"
}
        
Elapsed time: 0.48870s