Skip to content

Commit

Permalink
Merge pull request #717 from fractal-analytics-platform/697-update-ci…
Browse files Browse the repository at this point in the history
…-so-that-it-does-not-start-fractal-server-from-within-python

Run all CI against a single fractal-server instance
  • Loading branch information
ychiucco authored Oct 29, 2024
2 parents 1cea2d1 + 928bd8f commit 261a7e3
Show file tree
Hide file tree
Showing 25 changed files with 726 additions and 1,107 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: fractal_client_test
POSTGRES_DB: pytest-fractal-client
options: >-
--health-cmd pg_isready
--health-interval 10s
Expand Down Expand Up @@ -50,8 +50,17 @@ jobs:
- name: Test with pytest
env:
COVERAGE_FILE: coverage-data-${{ matrix.python-version }}
GHA_FRACTAL_SERVER_LOG: /tmp
run: poetry run coverage run -m pytest

- name: Log server STDOUT if pytest failed
if: failure()
run: cat /tmp/server_out

- name: Log server STDERR if pytest failed
if: failure()
run: cat /tmp/server_err

- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pip_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:

Expand Down
15 changes: 12 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

# 2.3.0

> WARNING: Starting from this release, Python3.9 is not supported any more.

* Align with [`fractal-server` 2.7.0](https://fractal-analytics-platform.github.io/fractal-server/changelog/#270) (\#712).
* Remove `--new-name` and `--new-version` options from `task edit` command (\#712).
* Rename `source` into `label` `task collect-custom` command (\#712).
* Do not rely on tasks' `source` or `owner` attributes (\#712).
* Add `--new-ssh-settings-json` to `fractal user edit` (\#715).
* Rename `source` into `label`, for `task collect-custom` command (\#712).
* Do not refer to obsolete task attributes `source` or `owner` (\#712, \#717).
* Add `--new-ssh-settings-json` option to `fractal user edit` (\#715).
* Add `--private` option to task-creating commands (\#717).
* Drop `task delete` command (\#717).
* Testing:
* Run all tests against a single `fractal-server` instance (\#717).
* Run tests in random module order, based on `pytest-randomly` (\#717).
* Include Python3.12 in GitHub CI (\#717).

# 2.2.1

Expand Down
8 changes: 3 additions & 5 deletions fractal_client/cmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from ._project import get_project_list
from ._project import patch_project
from ._project import post_project
from ._task import delete_task
from ._task import get_task_list
from ._task import patch_task
from ._task import post_task
Expand Down Expand Up @@ -136,6 +135,7 @@ def task(
"python_version",
"package_extras",
"pinned_dependency",
"private",
]
function_kwargs = get_kwargs(parameters, kwargs)
iface = task_collect_pip(client, batch=batch, **function_kwargs)
Expand All @@ -147,6 +147,7 @@ def task(
"version",
"package_name",
"package_root",
"private",
]
function_kwargs = get_kwargs(parameters, kwargs)
iface = task_collect_custom(client, batch=batch, **function_kwargs)
Expand All @@ -165,6 +166,7 @@ def task(
"args_schema_non_parallel",
"args_schema_parallel",
"args_schema_version",
"private",
]
function_kwargs = get_kwargs(parameters, kwargs)
iface = post_task(client, batch=batch, **function_kwargs)
Expand All @@ -180,10 +182,6 @@ def task(
]
function_kwargs = get_kwargs(parameters, kwargs)
iface = patch_task(client, **function_kwargs)
elif subcmd == "delete":
parameters = ["id", "name", "version"]
function_kwargs = get_kwargs(parameters, kwargs)
iface = delete_task(client, **function_kwargs)
else:
raise NoCommandError(f"Command 'task {subcmd}' not found")
return iface
Expand Down
7 changes: 2 additions & 5 deletions fractal_client/cmd/_aux_task_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,10 @@ def _format_task_list(task_list: _TaskList) -> str:
Helper function to print a formatted task list with only a few task
attributes, to be used in error messages.
"""
header = " ID, Name, Version, Source"
header = " ID, Name, Version"
formatted_list = "\n".join(
[
(
f' {task["id"]}, "{task["name"]}", {task["version"]}, '
f'{task["source"]}'
)
f' {task["id"]}, "{task["name"]}", {task["version"]}'
for task in task_list
]
)
Expand Down
41 changes: 11 additions & 30 deletions fractal_client/cmd/_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def task_collect_pip(
python_version: Optional[str] = None,
package_extras: Optional[str] = None,
pinned_dependency: Optional[list[str]] = None,
private: bool = False,
batch: bool = False,
) -> Interface:

Expand All @@ -49,8 +50,10 @@ def task_collect_pip(
for _name, _version in (p.split("=") for p in pinned_dependency)
}

is_private = "?private=true" if private else ""

res = client.post(
f"{settings.BASE_URL}/task/collect/pip/", json=task_collect
f"{settings.BASE_URL}/task/collect/pip/{is_private}", json=task_collect
)

state = check_response(res, expected_status_code=[200, 201])
Expand All @@ -70,6 +73,7 @@ def task_collect_custom(
version: Optional[str] = None,
package_name: Optional[str] = None,
package_root: Optional[str] = None,
private: bool = False,
batch: bool = False,
) -> Interface:

Expand All @@ -94,9 +98,11 @@ def task_collect_custom(
task_collect["package_name"] = package_name
if package_root:
task_collect["package_root"] = package_root
is_private = "?private=true" if private else ""

res = client.post(
f"{settings.BASE_URL}/task/collect/custom/", json=task_collect
f"{settings.BASE_URL}/task/collect/custom/{is_private}",
json=task_collect,
)

task_list = check_response(
Expand Down Expand Up @@ -141,6 +147,7 @@ def post_task(
args_schema_non_parallel: Optional[str] = None,
args_schema_parallel: Optional[str] = None,
args_schema_version: Optional[str] = None,
private: bool = False,
) -> Interface:
task = dict(name=name)
if command_non_parallel:
Expand All @@ -163,8 +170,9 @@ def post_task(
task["args_schema_non_parallel"] = json.load(f)
if args_schema_version:
task["args_schema_version"] = args_schema_version
is_private = "?private=true" if private else ""

res = client.post(f"{settings.BASE_URL}/task/", json=task)
res = client.post(f"{settings.BASE_URL}/task/{is_private}", json=task)
new_task = check_response(res, expected_status_code=201)

if batch:
Expand Down Expand Up @@ -215,30 +223,3 @@ def patch_task(
res = client.patch(f"{settings.BASE_URL}/task/{id}/", json=task_update)
new_task = check_response(res, expected_status_code=200)
return Interface(retcode=0, data=new_task)


def delete_task(
client: AuthClient,
*,
id: Optional[int] = None,
name: Optional[str] = None,
version: Optional[str] = None,
) -> Interface:

if id:
if version:
logging.error(
"Too many arguments: cannot provide both `id` and `version`."
)
sys.exit(1)
else:
try:
id = get_task_id_from_cache(
client=client, task_name=name, version=version
)
except FractalCacheError as e:
print(e)
sys.exit(1)
res = client.delete(f"{settings.BASE_URL}/task/{id}/")
check_response(res, expected_status_code=204)
return Interface(retcode=0, data="")
43 changes: 18 additions & 25 deletions fractal_client/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,12 @@
"pin several packages to specific versions."
),
)
task_collect_parser.add_argument(
"--private",
default=False,
action="store_true",
help="Make task group private.",
)


# task collect custom
Expand Down Expand Up @@ -278,6 +284,12 @@
"it will be automatically inferred based on 'package_name'."
),
)
task_collect_custom_parser.add_argument(
"--private",
default=False,
action="store_true",
help="Make task group private.",
)

# task check-collection
task_check_collection_parser = task_subparsers.add_parser(
Expand Down Expand Up @@ -341,6 +353,12 @@
"(e.g. `pydantic_v1`)."
),
)
task_new_parser.add_argument(
"--private",
default=False,
action="store_true",
help="Make task group private.",
)

# task edit
task_edit_parser = task_subparsers.add_parser(
Expand Down Expand Up @@ -384,31 +402,6 @@
help=("Path to JSON file with new output types."),
)

# task delete
task_delete_parser = task_subparsers.add_parser(
"delete",
description="Delete task.",
argument_default=ap.SUPPRESS,
allow_abbrev=False,
)
task_delete_id_or_name_group = task_delete_parser.add_mutually_exclusive_group(
required=True
)
task_delete_id_or_name_group.add_argument(
"--id", help="ID of the task to delete.", type=int
)
task_delete_id_or_name_group.add_argument(
"--name", help="Name of the task to delete."
)
task_delete_parser.add_argument(
"--version",
help=(
"Version of the task to delete "
"(only accepted in combination with `--name`)."
),
)


# WORKFLOW GROUP

workflow_parser = subparsers_main.add_parser(
Expand Down
Loading

0 comments on commit 261a7e3

Please sign in to comment.