Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #72 from PrefectHQ/sync-with-template
Browse files Browse the repository at this point in the history
Sync Collection with changes to prefect-collection-template
  • Loading branch information
ahuang11 authored Feb 21, 2023
2 parents 18d148f + 75afc8b commit beaa869
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/PrefectHQ/prefect-collection-template",
"commit": "f848dbf33334d22ade07b01ed17269bfa74d0f9c",
"commit": "a592f007ef24c0ada2527f0822e980571a5ae89f",
"checkout": null,
"context": {
"cookiecutter": {
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/nightly-dev-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Nightly tests against Prefect's main branch
on:
schedule:
- cron: "0 6 * * *"
workflow_dispatch:

jobs:
submit-update-pr:
name: Run tests against Prefect's main branch
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
fail-fast: false
steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements*.txt

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade --upgrade-strategy eager -e ".[dev]" "prefect @ git+https://github.com/PrefectHQ/prefect.git@main"
- name: Run tests
env:
PREFECT_API_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./collection-tests.db"
run: |
pytest tests -vv
2 changes: 1 addition & 1 deletion .github/workflows/template-sync.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Template Synchronization
on:
schedule:
- cron: "0 0 * * *"
- cron: "0 6 * * *"
workflow_dispatch:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Run tests
env:
PREFECT_ORION_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
PREFECT_ORION_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./tests.db"
run: |
coverage run --branch -m pytest tests -vv
coverage report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ jobs:
python -m pip install --upgrade --upgrade-strategy eager -e ".[dev]"
- name: Run tests
env:
PREFECT_ORION_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./orion-tests.db"
PREFECT_ORION_DATABASE_CONNECTION_URL: "sqlite+aiosqlite:///./tests.db"
run: |
pytest tests -vv
4 changes: 2 additions & 2 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ To verify the setup was successful you can run the following:

## Developing tasks and flows

For information about the use and development of tasks and flow, check out the [flows](https://orion-docs.prefect.io/concepts/flows/) and [tasks](https://orion-docs.prefect.io/concepts/tasks/) concepts docs in the Prefect docs.
For information about the use and development of tasks and flow, check out the [flows](https://docs.prefect.io/concepts/flows/) and [tasks](https://docs.prefect.io/concepts/tasks/) concepts docs in the Prefect docs.

## Writing documentation

Expand Down Expand Up @@ -99,7 +99,7 @@ To publish a new version of your collection, [create a new GitHub release](https
Upon publishing, a `docs` branch is automatically created. To hook this up to GitHub Pages, simply head over to https://github.com/PrefectHQ/prefect-ray/settings/pages, select `docs` under the dropdown menu, keep the default `/root` folder, `Save`, and upon refresh, you should see a prompt stating "Your site is published at https://PrefectHQ.github.io/prefect-ray". Don't forget to add this link to the repo's "About" section, under "Website" so users can access the docs easily.
Feel free to [submit your collection](https://orion-docs.prefect.io/collections/overview/#listing-in-the-collections-catalog) to the Prefect [Collections Catalog](https://orion-docs.prefect.io/collections/catalog/)!
Feel free to [submit your collection](https://docs.prefect.io/collections/overview/#listing-in-the-collections-catalog) to the Prefect [Collections Catalog](https://docs.prefect.io/collections/catalog/)!
## Further guidance
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Requires an installation of Python 3.7+.

We recommend using a Python virtual environment manager such as pipenv, conda, or virtualenv.

These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the [Prefect documentation](https://orion-docs.prefect.io/).
These tasks are designed to work with Prefect 2.0. For more information about how to use Prefect, please refer to the [Prefect documentation](https://docs.prefect.io/).

### Installation

Expand All @@ -52,7 +52,7 @@ Click [here](https://docs.ray.io/en/master/ray-overview/installation.html#m1-mac

## Running tasks on Ray

The `RayTaskRunner` is a [Prefect task runner](https://orion-docs.prefect.io/concepts/task-runners/) that submits tasks to [Ray](https://www.ray.io/) for parallel execution.
The `RayTaskRunner` is a [Prefect task runner](https://docs.prefect.io/concepts/task-runners/) that submits tasks to [Ray](https://www.ray.io/) for parallel execution.

By default, a temporary Ray instance is created for the duration of the flow run.

Expand Down
6 changes: 3 additions & 3 deletions docs/gen_blocks_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def insert_blocks_catalog(generated_file):
`prefect-ray`.
To register blocks in this module to
[view and edit them](https://orion-docs.prefect.io/ui/blocks/)
[view and edit them](https://docs.prefect.io/ui/blocks/)
on Prefect Cloud, first [install the required packages](
https://PrefectHQ.github.io/prefect-ray/#installation),
then
Expand All @@ -54,8 +54,8 @@ def insert_blocks_catalog(generated_file):
)
generated_file.write(
"Note, to use the `load` method on Blocks, you must already have a block document " # noqa
"[saved through code](https://orion-docs.prefect.io/concepts/blocks/#saving-blocks) " # noqa
"or [saved through the UI](https://orion-docs.prefect.io/ui/blocks/).\n"
"[saved through code](https://docs.prefect.io/concepts/blocks/#saving-blocks) " # noqa
"or [saved through the UI](https://docs.prefect.io/ui/blocks/).\n"
)
for module_nesting, block_names in module_blocks.items():
module_path = f"{COLLECTION_SLUG}." + " ".join(module_nesting)
Expand Down
11 changes: 7 additions & 4 deletions docs/gen_examples_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import re
from collections import defaultdict
from inspect import getmembers, isclass, isfunction, ismodule
from inspect import getmembers, isclass, isfunction
from pathlib import Path
from pkgutil import iter_modules
from textwrap import dedent
from types import ModuleType
from typing import Callable, Set, Union
Expand All @@ -15,7 +16,7 @@
from griffe.docstrings.dataclasses import DocstringSectionKind
from griffe.docstrings.parsers import Parser, parse
from prefect.logging.loggers import disable_logger
from prefect.utilities.importtools import to_qualified_name
from prefect.utilities.importtools import load_module, to_qualified_name

import prefect_ray

Expand Down Expand Up @@ -70,9 +71,11 @@ def get_code_examples(obj: Union[ModuleType, Callable]) -> Set[str]:


code_examples_grouping = defaultdict(set)
for module_name, module_obj in getmembers(prefect_ray, ismodule):
for _, module_name, ispkg in iter_modules(prefect_ray.__path__):

module_nesting = f"{COLLECTION_SLUG}.{module_name}"
module_obj = load_module(module_nesting)

# find all module examples
if skip_parsing(module_name, module_obj, module_nesting):
continue
Expand All @@ -89,7 +92,7 @@ def get_code_examples(obj: Union[ModuleType, Callable]) -> Set[str]:
code_examples_grouping[module_name] |= get_code_examples(method_obj)

# find all function examples
for function_name, function_obj in getmembers(module_obj, isfunction):
for function_name, function_obj in getmembers(module_obj, callable):
if skip_parsing(function_name, function_obj, module_nesting):
continue
code_examples_grouping[module_name] |= get_code_examples(function_obj)
Expand Down
44 changes: 44 additions & 0 deletions docs/stylesheets/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,48 @@ useful for wrapping table cell text in a span
to force column width */
.no-wrap {
white-space: nowrap;
}

/* dark mode slate theme */
/* dark mode code overrides */
[data-md-color-scheme="slate"] {
--md-code-bg-color: #252a33;
--md-code-fg-color: #eee;
--md-code-hl-color: #3b3d54;
--md-code-hl-name-color: #eee;
}

/* dark mode link overrides */
[data-md-color-scheme="slate"] .md-typeset a {
color: var(--blue);
}

[data-md-color-scheme="slate"] .md-typeset a:hover {
font-weight: bold;
}

/* dark mode nav overrides */
[data-md-color-scheme="slate"] .md-nav--primary .md-nav__item--active>.md-nav__link {
color: var(--blue);
font-weight: bold;
}

[data-md-color-scheme="slate"] .md-nav--primary .md-nav__link--active {
color: var(--blue);
font-weight: bold;
}

/* dark mode collection catalog overrides */
[data-md-color-scheme="slate"] .collection-item {
background-color: #3b3d54;
}

/* dark mode recipe collection overrides */
[data-md-color-scheme="slate"] .recipe-item {
background-color: #3b3d54;
}

/* dark mode API doc overrides */
[data-md-color-scheme="slate"] .prefect-table th {
background-color: #3b3d54;
}
49 changes: 0 additions & 49 deletions docs/stylesheets/extra.css.rej

This file was deleted.

4 changes: 2 additions & 2 deletions prefect_ray/task_runners.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Interface and implementations of the Ray Task Runner.
[Task Runners](https://orion-docs.prefect.io/api-ref/prefect/task-runners/)
[Task Runners](https://docs.prefect.io/api-ref/prefect/task-runners/)
in Prefect are responsible for managing the execution of Prefect task runs.
Generally speaking, users are not expected to interact with
task runners outside of configuring and initializing them for a flow.
Expand Down Expand Up @@ -78,7 +78,7 @@ def count_to(highest_number):
import anyio
import ray
from prefect.futures import PrefectFuture
from prefect.orion.schemas.states import State
from prefect.server.schemas.states import State
from prefect.states import exception_to_crashed_state
from prefect.task_runners import BaseTaskRunner, R, TaskConcurrencyType
from prefect.utilities.asyncutils import sync_compatible
Expand Down

0 comments on commit beaa869

Please sign in to comment.