Skip to content

Commit

Permalink
update the existing example to use the new toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
steinwaywhw committed Aug 19, 2024
1 parent 7127932 commit 18272a4
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 830 deletions.
7 changes: 4 additions & 3 deletions basics/generate-text/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ ts-node example-multi.ts # Run the MultiComputeText example

# Run the Python example
# Note: First install dependencies in the root examples directory.
cd python # Navigate to the python example
poetry run python example.py # Run the ComputeText example
poetry run python example-multi.py # Run the MultiComputeText example
cd python # Navigate to the python example
poetry install # Install dependencies and build the example
poetry run example # Run the ComputeText example
poetry run example-multi # Run the MultiComputeText example
```

</details>
Expand Down
28 changes: 28 additions & 0 deletions basics/generate-text/python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Substrate GenerateText Examples

To run this example,

```bash
# Set your API key as an environment variable.
# Get one here https://www.substrate.run/dashboard/keys if this is your first time.
export SUBSTRATE_API_KEY=<your Substrate API key>

# Navigate to the python example directory.
cd python
```

To run the example with Poetry, uncomment the Poetry sections in `pyproject.toml` and run the following.

```bash
poetry install
poetry run example
poetry run example-multi
```

To run the example with Rye, uncomment the Rye sections in `pyproject.toml` and run the following.

```bash
rye sync
rye run example
rye run example-multi
```
2 changes: 2 additions & 0 deletions basics/generate-text/python/poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
in-project = true
69 changes: 69 additions & 0 deletions basics/generate-text/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[project]
name = "example-generate-text"
version = "0.1.0"
description = ""
authors = [{ name = "Ben Guo", email = "[email protected]" }]
readme = "README.md"

requires-python = ">= 3.9"
dependencies = ["substrate"]

[project.scripts]
example = "generatetext.example:main"
example-multi = "generatetext.example_multi:main"

[tool.ruff]
line-length = 120
output-format = "grouped"
target-version = "py310"

[tool.pyright]
venvPath = "."
venv = ".venv"

##############################
# Uncomment for Poetry support
##############################

# [build-system]
# requires = ["poetry-core"]
# build-backend = "poetry.core.masonry.api"

# [tool.poetry]
# name = "example-generate-text"
# version = "0.1.0"
# description = ""
# authors = ["Ben Guo <[email protected]>"]
# readme = "README.md"

# packages = [{ include = "generatetext", from = "src" }]

# [tool.poetry.dependencies]
# python = "^3.9"
# substrate = "220240617.*"

# [tool.poetry.group.dev.dependencies]
# ruff = "^0.6.1"
# marimo = "^0.8.0"

# [tool.poetry.scripts]
# example = "generatetext.example:main"
# example-multi = "generatetext.example_multi:main"

###########################
# Uncomment for Rye support
###########################

# [build-system]
# requires = ["hatchling"]
# build-backend = "hatchling.build"

# [tool.rye]
# managed = true
# dev-dependencies = ["ruff>=0.6.1", "marimo>=0.8.0"]

# [tool.hatch.metadata]
# allow-direct-references = true

# [tool.hatch.build.targets.wheel]
# packages = ["src/generatetext"]
Empty file.
File renamed without changes.
Loading

0 comments on commit 18272a4

Please sign in to comment.