Skip to content
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

Run all CI against a single fractal-server instance #717

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
d3e52aa
chage fixtures: testserver, db, user_factory
ychiucco Oct 22, 2024
63fda78
fix test_project
ychiucco Oct 22, 2024
90ae118
make factories pure client
ychiucco Oct 22, 2024
6e436b0
testserver fixture calls script
ychiucco Oct 22, 2024
4597e84
fix some test workflow
ychiucco Oct 22, 2024
e192a17
remove unused fixture
ychiucco Oct 22, 2024
a734f8d
reduce yield
ychiucco Oct 22, 2024
07a872c
Add export
tcompa Oct 22, 2024
fff63ca
rewrite user_factory and register tester user on startup
ychiucco Oct 22, 2024
082fc0c
fix typo [skip ci]
ychiucco Oct 22, 2024
02c3f66
remove script and terminate process
ychiucco Oct 22, 2024
ee18756
use TESTER as known user
ychiucco Oct 22, 2024
ed56b4d
rm env file
ychiucco Oct 22, 2024
cff9577
clean up db
ychiucco Oct 22, 2024
7405f6f
dropdb, createdb
ychiucco Oct 22, 2024
36d73e1
new_name fixture
ychiucco Oct 22, 2024
c38d619
drop tables importing fractal_server
ychiucco Oct 22, 2024
a2b75c9
fix tests/test_workflow.py
ychiucco Oct 22, 2024
1afbfb0
removing blocking line for pytest
ychiucco Oct 22, 2024
6fd305b
fix tests/test_auth.py
ychiucco Oct 22, 2024
4b4df18
clean db the right way
ychiucco Oct 22, 2024
246635d
createdb/dropdb in session-scoped fixture, and change port
tcompa Oct 23, 2024
9b6b613
Use static db name
tcompa Oct 23, 2024
d801833
Add PGPASSWORD to GHA
tcompa Oct 23, 2024
2a7b134
Fix shlex
tcompa Oct 23, 2024
eb19600
Fix port
tcompa Oct 23, 2024
b8ec02c
Add POSTGRES_HOST variable
tcompa Oct 23, 2024
359ff5b
Add `--host` option
tcompa Oct 23, 2024
ccaa661
Add `--username=USERNAME`
tcompa Oct 23, 2024
f7b73e7
dropdb and then createdb
tcompa Oct 23, 2024
bad5da9
fix test dataset
ychiucco Oct 23, 2024
2be32e8
fix tests/test_group.py
ychiucco Oct 23, 2024
39cf8ff
fix test_project.py and test_user.py
ychiucco Oct 23, 2024
5325555
fix test_task.py
ychiucco Oct 23, 2024
0a1317b
add --private option
ychiucco Oct 23, 2024
a6ffe02
update gitignore
ychiucco Oct 23, 2024
e6a3ac3
clean
ychiucco Oct 23, 2024
68b315c
clean up service folder
ychiucco Oct 23, 2024
716f662
add --private option to post single task
ychiucco Oct 23, 2024
c6d57a5
fix test_task_collection.py
ychiucco Oct 23, 2024
981a30a
use session-scoped tmp folder
ychiucco Oct 23, 2024
51d8d2c
remove unused fixture
ychiucco Oct 23, 2024
c08ec20
poetry add pytest-randomly
ychiucco Oct 23, 2024
1b156b2
Merge branch 'main' into 697-update-ci-so-that-it-does-not-start-frac…
tcompa Oct 23, 2024
b0848ca
remove all register_user
ychiucco Oct 23, 2024
80fd55e
replace http with handle
ychiucco Oct 23, 2024
76299fd
check server is alive
ychiucco Oct 23, 2024
683a39c
pull bugfix from fractal-server
ychiucco Oct 24, 2024
98c6d80
fix test workflow import
ychiucco Oct 24, 2024
68953e6
TO REVERT
ychiucco Oct 24, 2024
d1dd65c
remove pytest-randomly
ychiucco Oct 24, 2024
fee210c
Revert "remove pytest-randomly"
ychiucco Oct 24, 2024
6c416e7
join two tests
ychiucco Oct 24, 2024
5b27912
poetry remove pytest-randomly
ychiucco Oct 24, 2024
d5e1cbd
pytest -v
ychiucco Oct 24, 2024
967919c
fractal 2.7.0a11
ychiucco Oct 24, 2024
bd3d99b
TO REVERT
ychiucco Oct 24, 2024
fca8c33
TO REVERT
ychiucco Oct 24, 2024
675eb4e
remove threads
ychiucco Oct 24, 2024
8502f31
add debug
ychiucco Oct 24, 2024
0c867b5
Use file descriptor for server logs
tcompa Oct 24, 2024
0d4c6b6
Add assertions to test-import-workflow
tcompa Oct 24, 2024
5140228
Merge branch '697-update-ci-so-that-it-does-not-start-fractal-server-…
tcompa Oct 24, 2024
6d00f55
run fractal-server as an external service
ychiucco Oct 24, 2024
3f4ba13
poetry add pytest-randomly
ychiucco Oct 24, 2024
a88e7c6
remove -s -v from pytest
ychiucco Oct 24, 2024
6e9c8a2
drop-create db in serve.sh
ychiucco Oct 24, 2024
d255076
add --host=localhost
ychiucco Oct 24, 2024
a152ddc
move redirect
ychiucco Oct 24, 2024
6fe8dec
use --no-password
ychiucco Oct 24, 2024
c1491f6
fix redirect
ychiucco Oct 24, 2024
be59c09
use password
ychiucco Oct 24, 2024
ecc2e3d
Revert "TO REVERT"
ychiucco Oct 24, 2024
0e00b42
Revert "run fractal-server as an external service"
ychiucco Oct 24, 2024
db0b262
print server out/err paths
ychiucco Oct 24, 2024
e801566
GHA_FRACTAL_SERVER_LOG
ychiucco Oct 24, 2024
a3d7b09
fix previous commit
ychiucco Oct 24, 2024
b85ab08
wrap with quotes
ychiucco Oct 24, 2024
1139f7f
add missing /
ychiucco Oct 24, 2024
0ff95c3
split step in gha
ychiucco Oct 24, 2024
aa1bb0c
use failure()
ychiucco Oct 24, 2024
eae430b
Small changes to fixture
tcompa Oct 25, 2024
92d9880
fix TypeError: dict() got multiple values for keyword argument 'PGPAS…
ychiucco Oct 25, 2024
e2a87f4
Update ci.yml
tcompa Oct 25, 2024
a8ae46f
Revert "fix TypeError: dict() got multiple values for keyword argumen…
ychiucco Oct 25, 2024
d6add32
dataset factory
ychiucco Oct 25, 2024
ac1aaf1
Remove job-factory fixture
tcompa Oct 25, 2024
e93af04
First cleanup of `job` test
tcompa Oct 25, 2024
56fc041
Drop python3.9 and add python3.12 in GH CI
tcompa Oct 25, 2024
4303983
Drop python3.9 and add python3.12 in pip-install GHA
tcompa Oct 25, 2024
dc585da
Use one-liner for private
tcompa Oct 25, 2024
9d27de0
Add test for single-task private
tcompa Oct 25, 2024
8ed75fd
Review new_name fixture
tcompa Oct 25, 2024
d5ccfdf
Fix test
tcompa Oct 25, 2024
268fbb2
Remove obsolete test
tcompa Oct 25, 2024
2410906
Drop obsolete delete-task command
tcompa Oct 25, 2024
344bb0d
Deprecate python3.9
tcompa Oct 25, 2024
585899c
Bump fractal-server in poetry lock
tcompa Oct 25, 2024
0039901
Increase timeout
tcompa Oct 25, 2024
ac6b07b
Improve use of `time.sleep` in tests
tcompa Oct 25, 2024
82b0159
Remove obsolete script
tcompa Oct 25, 2024
97c9ab3
Use example.org for most example emails
tcompa Oct 25, 2024
8abc2e2
Drop task `source`s from formatted task list
tcompa Oct 25, 2024
cc83766
Drop task `source` from tests
tcompa Oct 25, 2024
91dc383
CHANGELOG [skip ci]
tcompa Oct 25, 2024
928bd8f
move fixture and use tester in invoke
ychiucco Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading