-
Notifications
You must be signed in to change notification settings - Fork 7
Update dependency verification doc, pull out snippets #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| {/* Auto-generated by scripts/mdx_snippets_gen.py. Do not edit manually. */} | ||
|
|
||
| export const PyCondaManifestInline = "from geneva.manifest.builder import CondaManifestBuilder\n\nmanifest = (\n CondaManifestBuilder.create(\"my-manifest\")\n .conda({\n \"channels\": [\"conda-forge\"],\n \"dependencies\": [\n \"python=3.10\",\n \"ffmpeg<8\",\n \"torchvision=0.22.1\",\n ],\n })\n .build()\n)\n"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| export const PyCondaManifestPath = "from geneva.manifest.builder import CondaManifestBuilder\n\nmanifest = (\n CondaManifestBuilder.create(\"my-manifest\")\n .conda_environment_path(\"environment.yml\")\n .build()\n)\n"; | ||
|
|
||
| export const PyCondaClusterInline = "from geneva.cluster.builder import KubeRayClusterBuilder\n\ncluster = (\n KubeRayClusterBuilder.create(\"my-cluster\")\n .ray_init_kwargs({\n \"runtime_env\": {\n \"conda\": {\n \"channels\": [\"conda-forge\"],\n \"dependencies\": [\n \"python=3.10\",\n \"ffmpeg<8\",\n \"torchvision=0.22.1\",\n ],\n },\n \"config\": {\"eager_install\": True},\n }\n })\n .build()\n)\n"; | ||
|
|
||
| export const PyCondaClusterPath = "from geneva.cluster.builder import KubeRayClusterBuilder\n\ncluster = (\n KubeRayClusterBuilder.create(\"my-cluster\")\n .ray_init_kwargs({\n \"runtime_env\": {\"conda\": \"environment.yml\"}\n })\n .build()\n)\n"; | ||
|
|
||
| export const PyEnvVarsViaCluster = "from geneva.cluster.builder import KubeRayClusterBuilder\nimport os\n\ncluster = (\n KubeRayClusterBuilder.create(\"my-cluster\")\n .ray_init_kwargs({\n \"runtime_env\": {\n \"env_vars\": {\n \"AWS_ACCESS_KEY_ID\": os.environ[\"AWS_ACCESS_KEY_ID\"],\n \"AWS_SECRET_ACCESS_KEY\": os.environ[\"AWS_SECRET_ACCESS_KEY\"],\n }\n }\n })\n .build()\n)\n"; | ||
|
|
||
| export const PyPipManifest = "import geneva\nfrom geneva.manifest.builder import PipManifestBuilder\n\nmanifest = (\n PipManifestBuilder.create(\"my-manifest\")\n .pip([\n \"numpy==1.26.4\",\n \"torch==2.0.1\",\n \"attrs==23.2.0\",\n ])\n .build()\n)\n\nconn = geneva.connect(\"s3://my-bucket/my-db\")\nconn.define_manifest(\"my-manifest\", manifest)\nwith conn.context(cluster=\"my-cluster\", manifest=\"my-manifest\"):\n conn.open_table(\"my-table\").backfill(\"my-column\")\n"; | ||
|
|
||
| export const PyQuickFixManifest = "from geneva.manifest.builder import PipManifestBuilder\n\nmanifest = PipManifestBuilder.create(\"fix\").pip([\"numpy==1.26.4\"]).build()\n"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ name = "docs" | |
| version = "0.1.0" | ||
| description = "Add your description here" | ||
| readme = "README.md" | ||
| requires-python = ">=3.13" | ||
| requires-python = ">=3.12,<3.14" | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Geneva needs 3.12 :(
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm adding 3.13 right now.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and actually has been supporting 3.10 but this looks good to me.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. woohoo! ok, sounds good. |
||
| dependencies = [ | ||
| "lancedb>=0.29.2", | ||
| "lance-namespace>=0.5.2", | ||
|
|
@@ -13,4 +13,5 @@ dependencies = [ | |
| "pytest>=9.0.1", | ||
| "pytest-asyncio>=1.3.0", | ||
| "Pillow>=11.0.0", | ||
| "geneva>=0.11.0", | ||
| ] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # SPDX-FileCopyrightText: Copyright The LanceDB Authors | ||
|
|
||
| import os | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| def test_quick_fix_manifest(): | ||
| # --8<-- [start:quick_fix_manifest] | ||
| from geneva.manifest.builder import PipManifestBuilder | ||
|
|
||
| manifest = PipManifestBuilder.create("fix").pip(["numpy==1.26.4"]).build() | ||
| # --8<-- [end:quick_fix_manifest] | ||
| assert manifest.pip == ["numpy==1.26.4"] | ||
|
|
||
|
|
||
| def test_env_vars_via_cluster(monkeypatch): | ||
| monkeypatch.setenv("AWS_ACCESS_KEY_ID", "test-key-id") | ||
| monkeypatch.setenv("AWS_SECRET_ACCESS_KEY", "test-secret") | ||
|
|
||
| # --8<-- [start:env_vars_via_cluster] | ||
| from geneva.cluster.builder import KubeRayClusterBuilder | ||
| import os | ||
|
|
||
| cluster = ( | ||
| KubeRayClusterBuilder.create("my-cluster") | ||
| .ray_init_kwargs({ | ||
| "runtime_env": { | ||
| "env_vars": { | ||
| "AWS_ACCESS_KEY_ID": os.environ["AWS_ACCESS_KEY_ID"], | ||
| "AWS_SECRET_ACCESS_KEY": os.environ["AWS_SECRET_ACCESS_KEY"], | ||
| } | ||
| } | ||
| }) | ||
| .build() | ||
| ) | ||
| # --8<-- [end:env_vars_via_cluster] | ||
| assert cluster.kuberay.ray_init_kwargs["runtime_env"]["env_vars"]["AWS_ACCESS_KEY_ID"] == "test-key-id" | ||
|
|
||
|
|
||
| def test_pip_manifest(monkeypatch): | ||
| from unittest.mock import MagicMock | ||
| mock_conn = MagicMock() | ||
| monkeypatch.setattr("geneva.connect", MagicMock(return_value=mock_conn)) | ||
|
|
||
| # --8<-- [start:pip_manifest] | ||
| import geneva | ||
| from geneva.manifest.builder import PipManifestBuilder | ||
|
|
||
| manifest = ( | ||
| PipManifestBuilder.create("my-manifest") | ||
| .pip([ | ||
| "numpy==1.26.4", | ||
| "torch==2.0.1", | ||
| "attrs==23.2.0", | ||
| ]) | ||
| .build() | ||
| ) | ||
|
|
||
| conn = geneva.connect("s3://my-bucket/my-db") | ||
| conn.define_manifest("my-manifest", manifest) | ||
| with conn.context(cluster="my-cluster", manifest="my-manifest"): | ||
| conn.open_table("my-table").backfill("my-column") | ||
| # --8<-- [end:pip_manifest] | ||
| assert "numpy==1.26.4" in manifest.pip | ||
|
|
||
|
|
||
| def test_conda_cluster_path(): | ||
| # --8<-- [start:conda_cluster_path] | ||
| from geneva.cluster.builder import KubeRayClusterBuilder | ||
|
|
||
| cluster = ( | ||
| KubeRayClusterBuilder.create("my-cluster") | ||
| .ray_init_kwargs({ | ||
| "runtime_env": {"conda": "environment.yml"} | ||
| }) | ||
| .build() | ||
| ) | ||
| # --8<-- [end:conda_cluster_path] | ||
| assert cluster.kuberay.ray_init_kwargs["runtime_env"]["conda"] == "environment.yml" | ||
|
|
||
|
|
||
| def test_conda_cluster_inline(): | ||
| # --8<-- [start:conda_cluster_inline] | ||
| from geneva.cluster.builder import KubeRayClusterBuilder | ||
|
|
||
| cluster = ( | ||
| KubeRayClusterBuilder.create("my-cluster") | ||
| .ray_init_kwargs({ | ||
| "runtime_env": { | ||
| "conda": { | ||
| "channels": ["conda-forge"], | ||
| "dependencies": [ | ||
| "python=3.10", | ||
| "ffmpeg<8", | ||
| "torchvision=0.22.1", | ||
| ], | ||
| }, | ||
| "config": {"eager_install": True}, | ||
| } | ||
| }) | ||
| .build() | ||
| ) | ||
| # --8<-- [end:conda_cluster_inline] | ||
| assert cluster.kuberay.ray_init_kwargs["runtime_env"]["conda"]["channels"] == ["conda-forge"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This little bit is still untested because the env_vars method was just added today; once it's in the next release we can pull it out into a snippet as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both of these apis are valid but pip is preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, GenevaManifestBuilder doesn't exist anymore, that's what got me started on this whole thing anyway 😆