# ModelPark
ModelPark provides a versatile platform to share and manage your ML models directly from your machine, offering a convenient Python API to manage these tasks programmatically, including controlling access and publishing applications.
This library provides a more Pythonic way of managing your applications with [ModelPark](https://modelpark.app/) compared to using the CLI directly.
See [ModelPark](https://modelpark.app/) website and platform for more details.
![image](https://github.com/model-park/modelpark/assets/25637056/6eac80e7-91e9-477a-bcce-bd7d369d932e)
![image](https://github.com/model-park/modelpark/assets/25637056/be495106-915d-4989-818d-dad7bb5abc71)
## Features
- Share models directly from the Python API.
- Publish and manage applications using the ModelPark Python API.
- Configure access management according to your needs through Python methods.
## Installation
To install ModelPark, you can use pip:
```bash
pip install modelpark
```
## Configuration
Ensure Python and pip are installed on your machine. This API interfaces with the ModelPark CLI but manages interactions programmatically through Python.
## Usage
Here's how you can use the ModelPark Python package:
### Initialize and Login
```python
from modelpark import ModelPark
mp = ModelPark() # downloads the modelpark CLI binary/ executable to your home folder as "~/modelpark'
mp.login(username="your_username", password="your_password")
mp.init()
```
#### clear cache while init (remove existing modelpark CLI binaries from system)
```python
from modelpark import ModelPark
mp = ModelPark(clear_cache=True)
```
### Register an Application
#### Register an app running on a certain port
```python
mp.register(port=3000, name="my-app", access="public")
# access='private' if private (not visible/ accessible in modelpark dashboard)
```
#### Register a password protected app running on a certain port
```python
mp.register_port(port=3000, name="my-app", access="public", password='123')
```
#### Register an app running on a certain port
```python
mp.register_port(port=3000, name="my-app", access="public")
```
#### Register a streamlit app that is not run yet (this starts the app as well)
```python
mp.run_with_streamlit_and_register(port=3000, name="my-app", file_path="~/my-app/streamlit-app.py", access="public", framework="streamlit")
# generic registration also works >>
# mp.register(port=3000, name="my-app", file_path="~/my-app/streamlit-app.py", access="public", framework="streamlit")
```
#### Register a streamlit app that is not run yet
```python
mp.register(port=3000, name="my-app", file_path="~/my-app/streamlit-app.py", access="public", framework="streamlit")
```
#### Register a Fast API app while deploying
add `register_port` within startup_event() function in FAST API app
```python
@app.on_event("startup")
async def startup_event():
mp.register_port(port=5000, name="my-fast-api", access="public")
```
### List Registered Applications
```python
mp.ls()
# or mp.status()
```
### Make an API Call to a Registered Application
```python
from modelpark import APIManager
mp_api = APIManager()
user_credentials = {'username': 'your_username', 'password': 'your_password'}
app_name = 'my-app'
payload = {'key': 'value'} # Payload required by the application
# Make the API call
response = mp_api.make_api_call(app_name, user_credentials, payload)
print(response.json()) # Assuming the response is in JSON format
```
### Stop and Logout
```python
mp.stop()
mp.logout()
```
### Kill an Application
```python
mp.kill(name="my-app")
```
### Kill all the registrations in this session
```python
mp.kill(all=True)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/model-park/modelpark",
"name": "modelpark",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "modelpark, deployment, cloud, api",
"author": "Veysel Kocaman",
"author_email": "info@modelpark.app",
"download_url": "https://files.pythonhosted.org/packages/0a/7d/85061f9cd7b2121e88691c662c6374c399fc7a0532adbcf1811b5a69fafa/modelpark-0.1.15.tar.gz",
"platform": null,
"description": "\n# ModelPark\n\nModelPark provides a versatile platform to share and manage your ML models directly from your machine, offering a convenient Python API to manage these tasks programmatically, including controlling access and publishing applications.\n\nThis library provides a more Pythonic way of managing your applications with [ModelPark](https://modelpark.app/) compared to using the CLI directly.\n\nSee [ModelPark](https://modelpark.app/) website and platform for more details.\n\n![image](https://github.com/model-park/modelpark/assets/25637056/6eac80e7-91e9-477a-bcce-bd7d369d932e)\n\n![image](https://github.com/model-park/modelpark/assets/25637056/be495106-915d-4989-818d-dad7bb5abc71)\n\n## Features\n\n- Share models directly from the Python API.\n- Publish and manage applications using the ModelPark Python API.\n- Configure access management according to your needs through Python methods.\n\n## Installation\n\nTo install ModelPark, you can use pip:\n```bash\npip install modelpark\n```\n\n## Configuration\n\nEnsure Python and pip are installed on your machine. This API interfaces with the ModelPark CLI but manages interactions programmatically through Python.\n\n## Usage\n\nHere's how you can use the ModelPark Python package:\n\n### Initialize and Login\n```python\nfrom modelpark import ModelPark\n\nmp = ModelPark() # downloads the modelpark CLI binary/ executable to your home folder as \"~/modelpark'\nmp.login(username=\"your_username\", password=\"your_password\")\nmp.init()\n```\n\n#### clear cache while init (remove existing modelpark CLI binaries from system)\n```python\nfrom modelpark import ModelPark\n\nmp = ModelPark(clear_cache=True)\n```\n\n### Register an Application \n\n#### Register an app running on a certain port\n```python\nmp.register(port=3000, name=\"my-app\", access=\"public\") \n# access='private' if private (not visible/ accessible in modelpark dashboard)\n```\n#### Register a password protected app running on a certain port\n\n```python\nmp.register_port(port=3000, name=\"my-app\", access=\"public\", password='123')\n```\n\n#### Register an app running on a certain port\n\n```python\nmp.register_port(port=3000, name=\"my-app\", access=\"public\")\n```\n\n#### Register a streamlit app that is not run yet (this starts the app as well)\n```python\nmp.run_with_streamlit_and_register(port=3000, name=\"my-app\", file_path=\"~/my-app/streamlit-app.py\", access=\"public\", framework=\"streamlit\")\n# generic registration also works >> \n# mp.register(port=3000, name=\"my-app\", file_path=\"~/my-app/streamlit-app.py\", access=\"public\", framework=\"streamlit\")\n\n```\n\n#### Register a streamlit app that is not run yet \n```python\nmp.register(port=3000, name=\"my-app\", file_path=\"~/my-app/streamlit-app.py\", access=\"public\", framework=\"streamlit\")\n```\n\n#### Register a Fast API app while deploying\nadd `register_port` within startup_event() function in FAST API app\n```python\n@app.on_event(\"startup\")\nasync def startup_event():\n mp.register_port(port=5000, name=\"my-fast-api\", access=\"public\") \n``` \n\n### List Registered Applications\n```python\nmp.ls()\n# or mp.status()\n```\n\n### Make an API Call to a Registered Application\n```python\nfrom modelpark import APIManager\nmp_api = APIManager()\n\nuser_credentials = {'username': 'your_username', 'password': 'your_password'}\napp_name = 'my-app'\npayload = {'key': 'value'} # Payload required by the application\n\n# Make the API call\nresponse = mp_api.make_api_call(app_name, user_credentials, payload)\nprint(response.json()) # Assuming the response is in JSON format\n```\n\n### Stop and Logout\n```python\nmp.stop()\nmp.logout()\n```\n\n### Kill an Application\n```python\nmp.kill(name=\"my-app\")\n```\n\n### Kill all the registrations in this session\n```python\nmp.kill(all=True)\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Versatile solution for sharing apps through secure URLs",
"version": "0.1.15",
"project_urls": {
"Homepage": "https://github.com/model-park/modelpark"
},
"split_keywords": [
"modelpark",
" deployment",
" cloud",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "047aa027ab06dabfa611a923cf71fcb80f825feaf3f53b00f5ea24c62648efa1",
"md5": "a2a2a819f20cd7997af9b4f3e7771fed",
"sha256": "ab4f613231d62e7dff781612660f754a76749eeb2f5f46ee6fd2ccaa6e4c2b59"
},
"downloads": -1,
"filename": "modelpark-0.1.15-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a2a2a819f20cd7997af9b4f3e7771fed",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6196,
"upload_time": "2024-05-01T22:48:27",
"upload_time_iso_8601": "2024-05-01T22:48:27.731406Z",
"url": "https://files.pythonhosted.org/packages/04/7a/a027ab06dabfa611a923cf71fcb80f825feaf3f53b00f5ea24c62648efa1/modelpark-0.1.15-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0a7d85061f9cd7b2121e88691c662c6374c399fc7a0532adbcf1811b5a69fafa",
"md5": "c1f128fc0a1cce335f09f68fb38c3c7a",
"sha256": "29fdbba36ef2b464255457da92a81862502da24ad16c23a9b254eccf43c05a09"
},
"downloads": -1,
"filename": "modelpark-0.1.15.tar.gz",
"has_sig": false,
"md5_digest": "c1f128fc0a1cce335f09f68fb38c3c7a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5844,
"upload_time": "2024-05-01T22:48:29",
"upload_time_iso_8601": "2024-05-01T22:48:29.290461Z",
"url": "https://files.pythonhosted.org/packages/0a/7d/85061f9cd7b2121e88691c662c6374c399fc7a0532adbcf1811b5a69fafa/modelpark-0.1.15.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-01 22:48:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "model-park",
"github_project": "modelpark",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "modelpark"
}