{"id":19643754,"url":"https://github.com/logicalclocks/hopsworks-api","last_synced_at":"2025-04-05T14:03:21.924Z","repository":{"id":36950884,"uuid":"427596799","full_name":"logicalclocks/hopsworks-api","owner":"logicalclocks","description":"Python SDK to interact with the Hopsworks API","archived":false,"fork":false,"pushed_at":"2024-10-24T15:19:01.000Z","size":70675,"stargazers_count":8,"open_issues_count":7,"forks_count":26,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-10-25T05:07:46.942Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/logicalclocks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-13T07:21:45.000Z","updated_at":"2024-10-24T15:19:06.000Z","dependencies_parsed_at":"2023-10-12T18:00:37.158Z","dependency_job_id":"d8efba0e-a660-4559-86cd-ffe271d0a967","html_url":"https://github.com/logicalclocks/hopsworks-api","commit_stats":{"total_commits":74,"total_committers":7,"mean_commits":"10.571428571428571","dds":"0.17567567567567566","last_synced_commit":"483320732b848c3aa11ab8cfc5ee55745498d4b2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalclocks%2Fhopsworks-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalclocks%2Fhopsworks-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalclocks%2Fhopsworks-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/logicalclocks%2Fhopsworks-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/logicalclocks","download_url":"https://codeload.github.com/logicalclocks/hopsworks-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247345849,"owners_count":20924102,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T14:23:44.899Z","updated_at":"2025-04-05T14:03:21.906Z","avatar_url":"https://github.com/logicalclocks.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hopsworks Client\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://community.hopsworks.ai\"\u003e\u003cimg\n    src=\"https://img.shields.io/discourse/users?label=Hopsworks%20Community\u0026server=https%3A%2F%2Fcommunity.hopsworks.ai\"\n    alt=\"Hopsworks Community\"\n  /\u003e\u003c/a\u003e\n    \u003ca href=\"https://docs.hopsworks.ai\"\u003e\u003cimg\n    src=\"https://img.shields.io/badge/docs-HOPSWORKS-orange\"\n    alt=\"Hopsworks Documentation\"\n  /\u003e\u003c/a\u003e\n  \u003ca\u003e\u003cimg\n    src=\"https://img.shields.io/badge/python-3.8+-blue\"\n    alt=\"python\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=\"https://pypi.org/project/hopsworks/\"\u003e\u003cimg\n    src=\"https://img.shields.io/pypi/v/hopsworks?color=blue\"\n    alt=\"PyPiStatus\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=\"https://archiva.hops.works/#artifact/com.logicalclocks/hopsworks\"\u003e\u003cimg\n    src=\"https://img.shields.io/badge/java-HOPSWORKS-green\"\n    alt=\"Scala/Java Artifacts\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=\"https://pepy.tech/project/hopsworks/month\"\u003e\u003cimg\n    src=\"https://pepy.tech/badge/hopsworks/month\"\n    alt=\"Downloads\"\n  /\u003e\u003c/a\u003e\n  \u003ca href=https://github.com/astral-sh/ruff\u003e\u003cimg\n    src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\"\n    alt=\"Ruff\"\n  /\u003e\u003c/a\u003e\n  \u003ca\u003e\u003cimg\n    src=\"https://img.shields.io/pypi/l/hopsworks?color=green\"\n    alt=\"License\"\n  /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n*hopsworks* is the python API for interacting with a Hopsworks cluster. Don't have a Hopsworks cluster just yet? Register an account on [Hopsworks Serverless](https://app.hopsworks.ai/) and get started for free. Once connected to your project, you can:\n\n- Insert dataframes into the online or offline Store, create training datasets or *serve real-time* feature vectors in the Feature Store via the Feature Store API. Already have data somewhere you want to import, checkout our [Storage Connectors](https://docs.hopsworks.ai/latest/user_guides/fs/storage_connector/) documentation.\n- register ML models in the model registry and *deploy* them via model serving via the Machine Learning API.\n- manage environments, executions, kafka topics and more once you deploy your own Hopsworks cluster, either on-prem or in the cloud. Hopsworks is open-source and has its own [Community Edition](https://github.com/logicalclocks/hopsworks).\n\nOur [tutorials](https://github.com/logicalclocks/hopsworks-tutorials) cover a wide range of use cases and example of what *you* can build using Hopsworks.\n\n## Getting Started On Hopsworks\n\nOnce you created a project on [Hopsworks Serverless](https://app.hopsworks.ai) and created a new [Api Key](https://docs.hopsworks.ai/latest/user_guides/projects/api_key/create_api_key/), just use your favourite virtualenv and package manager to install the library:\n\n```bash\npip install \"hopsworks[python]\"\n```\n\nFire up a notebook and connect to your project, you will be prompted to enter your newly created API key:\n\n```python\nimport hopsworks\n\nproject = hopsworks.login()\n```\n\n### Feature Store API\n\nAccess the Feature Store of your project to use as a central repository for your feature data. Use *your* favourite data engineering library (pandas, polars, Spark, etc...) to insert data into the Feature Store, create training datasets or serve real-time feature vectors. Want to predict likelyhood of e-scooter accidents in real-time? Here's how you can do it:\n\n```python\nfs = project.get_feature_store()\n\n# Write to Feature Groups\nbike_ride_fg = fs.get_or_create_feature_group(\n  name=\"bike_rides\",\n  version=1,\n  primary_key=[\"ride_id\"],\n  event_time=\"activation_time\",\n  online_enabled=True,\n)\n\nfg.insert(bike_rides_df)\n\n# Read from Feature Views\nprofile_fg = fs.get_feature_group(\"user_profile\", version=1)\n\nbike_ride_fv = fs.get_or_create_feature_view(\n  name=\"bike_rides_view\",\n  version=1,\n  query=bike_ride_fg.select_except([\"ride_id\"]).join(profile_fg.select([\"age\", \"has_license\"]), on=\"user_id\")\n)\n\nbike_rides_Q1_2021_df = bike_ride_fv.get_batch_data(\n  start_date=\"2021-01-01\",\n  end_date=\"2021-01-31\"\n)\n\n# Create a training dataset\nversion, job = bike_ride_fv.create_train_test_split(\n    test_size=0.2,\n    description='Description of a dataset',\n    # you can have different data formats such as csv, tsv, tfrecord, parquet and others\n    data_format='csv'\n)\n\n# Predict the probability of accident in real-time using new data + context data\nbike_ride_fv.init_serving()\n\nwhile True:\n    new_ride_vector = poll_ride_queue()\n    feature_vector = bike_ride_fv.get_online_feature_vector(\n      {\"user_id\": new_ride_vector[\"user_id\"]},\n      passed_features=new_ride_vector\n    )\n    accident_probability = model.predict(feature_vector)\n```\n\nThe API enables interaction with the Hopsworks Feature Store. It makes creating new features, feature groups and training datasets easy.\n\nThe API is environment independent and can be used in two modes:\n\n- Spark mode: For data engineering jobs that create and write features into the feature store or generate training datasets. It requires a Spark environment such as the one provided in the Hopsworks platform or Databricks. In Spark mode, HSFS provides bindings both for Python and JVM languages.\n\n- Python mode: For data science jobs to explore the features available in the feature store, generate training datasets and feed them in a training pipeline. Python mode requires just a Python interpreter and can be used both in Hopsworks from Python Jobs/Jupyter Kernels, Amazon SageMaker or KubeFlow.\n\nScala API is also available, here is a short sample of it:\n\n```scala\nimport com.logicalclocks.hsfs._\nval connection = HopsworksConnection.builder().build()\nval fs = connection.getFeatureStore();\nval attendances_features_fg = fs.getFeatureGroup(\"games_features\", 1);\nattendances_features_fg.show(1)\n```\n\n### Machine Learning API\n\nOr you can use the Machine Learning API to interact with the Hopsworks Model Registry and Model Serving. The API makes it easy to export, manage and deploy models. For example, to register models and deploy them for serving you can do:\n\n```python\nmr = project.get_model_registry()\n# or\nms = connection.get_model_serving()\n\n# Create a new model:\nmodel = mr.tensorflow.create_model(name=\"mnist\",\n                                   version=1,\n                                   metrics={\"accuracy\": 0.94},\n                                   description=\"mnist model description\")\nmodel.save(\"/tmp/model_directory\") # or /tmp/model_file\n\n# Download a model:\nmodel = mr.get_model(\"mnist\", version=1)\nmodel_path = model.download()\n\n# Delete the model:\nmodel.delete()\n\n# Get the best-performing model\nbest_model = mr.get_best_model('mnist', 'accuracy', 'max')\n\n# Deploy the model:\ndeployment = model.deploy()\ndeployment.start()\n\n# Make predictions with a deployed model\ndata = { \"instances\": [ model.input_example ] }\npredictions = deployment.predict(data)\n```\n\n## Usage\n\nUsage data is collected for improving quality of the library.\nIt is turned on by default if the backend is [Hopsworks Serverless](https://c.app.hopsworks.ai).\nTo turn it off, use one of the following ways:\n```python\n# use environment variable\nimport os\nos.environ[\"ENABLE_HOPSWORKS_USAGE\"] = \"false\"\n\n# use `disable_usage_logging`\nimport hopsworks\nhopsworks.disable_usage_logging()\n```\n\nThe corresponding source code is in `python/hopsworks_common/usage.py`.\n\n## Tutorials\n\nNeed more inspiration or want to learn more about the Hopsworks platform? Check out our [tutorials](https://github.com/logicalclocks/hopsworks-tutorials).\n\n## Documentation\n\nDocumentation is available at [Hopsworks Documentation](https://docs.hopsworks.ai/).\n\n## Issues\n\nFor general questions about the usage of Hopsworks and the Feature Store please open a topic on [Hopsworks Community](https://community.hopsworks.ai/).\n\nPlease report any issue using [Github issue tracking](https://github.com/logicalclocks/hopsworks-api/issues) and attach the client environment from the output below to your issue:\n\n```python\nimport hopsworks\nhopsworks.login()\nprint(hopsworks.get_sdk_info())\n```\n\n## Contributing\n\nIf you would like to contribute to this library, please see the [Contribution Guidelines](CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogicalclocks%2Fhopsworks-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flogicalclocks%2Fhopsworks-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flogicalclocks%2Fhopsworks-api/lists"}