Name | inincompatibility JSON |
Version |
0.0.8
JSON |
| download |
home_page | None |
Summary | A dependency-free, code-less socket-based solution for resolving environment incompatibilities |
upload_time | 2024-12-26 10:13:37 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | MIT License Copyright (c) 2024 Elaina Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
compatibility
incompatibility
socket
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
inincompatibility
=================
A dependency-free, code-less ``socket``-based solution for resolving
(**Python** / **conda**) environment incompatibilities.
Usage Guidelines
----------------
**Installation**:
To install the ``inincompatibility`` package, run:
.. code:: shell
pip install inincompatibility
**Example: Making Your LLMs Callable Like an API**:
First, make your LLMs (e.g.,
`Llama-3.2-1B <https://huggingface.co/meta-llama/Llama-3.2-1B>`__)
callable functions:
.. code:: python
# your_llm.py
import torch
from transformers import pipeline as pl
m = "meta-llama/Llama-3.2-1B"
p = pl("text-generation", model=m, device="cuda")
def llm_qa(msg: list) -> dict:
return p(msg)[0]["generated_text"]
Next, create another Python file (e.g., ``to_import_ori.py``) to
``import`` the LLM function:
.. code:: python
# to_import_ori.py
from your_llm import llm_qa
Then, use the ``inincompatibility`` CLI to generate the necessary
importable code and then run the LLM in its (**Python** / **conda**)
environment:
.. code:: shell
conda activate llama
pip install inincompatibility
python -m inincompatibility -i to_import_ori.py -o to_import.py
A file named ``to_import.py`` (specified by the ``-o`` argument) will be
generated as follows:
.. code:: python
# Generated by `inincompatibility`.
# **Not** depend on `incompatibility`. :)
# You can directly `import` this file in another environment.
import socket
import pickle
BUFFER_SIZE = 65536
client = socket.socket(2, socket.SOCK_STREAM)
client.connect(('127.0.0.1', 57849))
def _func_eval(func, args, kwargs):
data = pickle.dumps((func, args, kwargs))
client.sendall(data)
return pickle.loads(client.recv(BUFFER_SIZE))
def _inincompatibility_remote_eval(*args, **kwargs):
return _func_eval('_inincompatibility_remote_eval', args, kwargs)
def _inincompatibility_remote_exec(*args, **kwargs):
return _func_eval('_inincompatibility_remote_exec', args, kwargs)
def llm_qa(*args, **kwargs):
return _func_eval('llm_qa', args, kwargs)
Now, you can directly ``import`` the generated code in another
(**Python** / **conda**) environment:
.. code:: python
# main.py
from to_import import llm_qa
print(llm_qa('The key to life is'))
Run your main script (e.g., ``main.py``) in the target environment:
.. code:: shell
conda activate blackbox
python main.py
For more details, check out the
`sample-llama <https://github.com/userElaina/inincompatibility/tree/main/sample-llama>`__
directory on
`GitHub <https://github.com/userElaina/inincompatibility>`__.
**Example: Additional Samples**:
For more usage examples, visit the
`sample-local <https://github.com/userElaina/inincompatibility/tree/main/sample-local>`__
directory on
`GitHub <https://github.com/userElaina/inincompatibility>`__.
Raw data
{
"_id": null,
"home_page": null,
"name": "inincompatibility",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "userElaina <userelaina@pm.me>",
"keywords": "compatibility, incompatibility, socket",
"author": null,
"author_email": "userElaina <userelaina@pm.me>",
"download_url": "https://files.pythonhosted.org/packages/15/24/ec33f59b9b29bb84c66e0c788f3989399a79eb06a905c4af1fdf0d8b9257/inincompatibility-0.0.8.tar.gz",
"platform": null,
"description": "inincompatibility\n=================\n\nA dependency-free, code-less ``socket``-based solution for resolving\n(**Python** / **conda**) environment incompatibilities.\n\nUsage Guidelines\n----------------\n\n**Installation**:\n\nTo install the ``inincompatibility`` package, run:\n\n.. code:: shell\n\n pip install inincompatibility\n\n**Example: Making Your LLMs Callable Like an API**:\n\nFirst, make your LLMs (e.g.,\n`Llama-3.2-1B <https://huggingface.co/meta-llama/Llama-3.2-1B>`__)\ncallable functions:\n\n.. code:: python\n\n # your_llm.py\n import torch\n from transformers import pipeline as pl\n\n m = \"meta-llama/Llama-3.2-1B\"\n p = pl(\"text-generation\", model=m, device=\"cuda\")\n\n def llm_qa(msg: list) -> dict:\n return p(msg)[0][\"generated_text\"]\n\nNext, create another Python file (e.g., ``to_import_ori.py``) to\n``import`` the LLM function:\n\n.. code:: python\n\n # to_import_ori.py\n from your_llm import llm_qa\n\nThen, use the ``inincompatibility`` CLI to generate the necessary\nimportable code and then run the LLM in its (**Python** / **conda**)\nenvironment:\n\n.. code:: shell\n\n conda activate llama\n pip install inincompatibility\n python -m inincompatibility -i to_import_ori.py -o to_import.py\n\nA file named ``to_import.py`` (specified by the ``-o`` argument) will be\ngenerated as follows:\n\n.. code:: python\n\n # Generated by `inincompatibility`.\n # **Not** depend on `incompatibility`. :)\n # You can directly `import` this file in another environment.\n import socket\n import pickle\n\n BUFFER_SIZE = 65536\n\n client = socket.socket(2, socket.SOCK_STREAM)\n client.connect(('127.0.0.1', 57849))\n\n def _func_eval(func, args, kwargs):\n data = pickle.dumps((func, args, kwargs))\n client.sendall(data)\n return pickle.loads(client.recv(BUFFER_SIZE))\n\n def _inincompatibility_remote_eval(*args, **kwargs):\n return _func_eval('_inincompatibility_remote_eval', args, kwargs)\n\n def _inincompatibility_remote_exec(*args, **kwargs):\n return _func_eval('_inincompatibility_remote_exec', args, kwargs)\n\n def llm_qa(*args, **kwargs):\n return _func_eval('llm_qa', args, kwargs)\n\nNow, you can directly ``import`` the generated code in another\n(**Python** / **conda**) environment:\n\n.. code:: python\n\n # main.py\n from to_import import llm_qa\n print(llm_qa('The key to life is'))\n\nRun your main script (e.g., ``main.py``) in the target environment:\n\n.. code:: shell\n\n conda activate blackbox\n python main.py\n\nFor more details, check out the\n`sample-llama <https://github.com/userElaina/inincompatibility/tree/main/sample-llama>`__\ndirectory on\n`GitHub <https://github.com/userElaina/inincompatibility>`__.\n\n**Example: Additional Samples**:\n\nFor more usage examples, visit the\n`sample-local <https://github.com/userElaina/inincompatibility/tree/main/sample-local>`__\ndirectory on\n`GitHub <https://github.com/userElaina/inincompatibility>`__.\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) 2024 Elaina Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "A dependency-free, code-less socket-based solution for resolving environment incompatibilities",
"version": "0.0.8",
"project_urls": {
"Bug Reports": "https://github.com/userElaina/inincompatibility/issues",
"Homepage": "https://github.com/userElaina/inincompatibility",
"Source": "https://github.com/userElaina/inincompatibility"
},
"split_keywords": [
"compatibility",
" incompatibility",
" socket"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3248ec8c337595171e5141350e8d87027c981967280adf85ae3afd0589f3c5af",
"md5": "6340efff8a17168e72299f1b6b260a39",
"sha256": "b344df1072073489fb2906311fdd87b8ff4f8d6c952b1086c7598ad2b68c46cd"
},
"downloads": -1,
"filename": "inincompatibility-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6340efff8a17168e72299f1b6b260a39",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 8145,
"upload_time": "2024-12-26T10:13:36",
"upload_time_iso_8601": "2024-12-26T10:13:36.239258Z",
"url": "https://files.pythonhosted.org/packages/32/48/ec8c337595171e5141350e8d87027c981967280adf85ae3afd0589f3c5af/inincompatibility-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1524ec33f59b9b29bb84c66e0c788f3989399a79eb06a905c4af1fdf0d8b9257",
"md5": "975a51aac5808b0270a13906e8e1b11d",
"sha256": "84c95f125965e7982c1deca6feb306df4fe7015011faf24d78d2bd99a5a43e42"
},
"downloads": -1,
"filename": "inincompatibility-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "975a51aac5808b0270a13906e8e1b11d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8061,
"upload_time": "2024-12-26T10:13:37",
"upload_time_iso_8601": "2024-12-26T10:13:37.691916Z",
"url": "https://files.pythonhosted.org/packages/15/24/ec33f59b9b29bb84c66e0c788f3989399a79eb06a905c4af1fdf0d8b9257/inincompatibility-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-26 10:13:37",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "userElaina",
"github_project": "inincompatibility",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "inincompatibility"
}