From 6727cbb3bc0f7383eab0caecb0e7279f8b42c8bf Mon Sep 17 00:00:00 2001 From: Jan-Lukas Wynen Date: Fri, 12 Apr 2024 14:10:47 +0200 Subject: [PATCH 1/3] Update pre-commit hooks --- .pre-commit-config.yaml | 4 +- docs/user-guide/downloading.ipynb | 48 +++++------ docs/user-guide/testing.ipynb | 98 +++++++++++------------ docs/user-guide/uploading.ipynb | 58 +++++++------- pyproject.toml | 19 ++--- src/scitacean/_base_model.py | 19 ++--- src/scitacean/_html_repr/__init__.py | 1 + src/scitacean/_internal/docker.py | 1 + src/scitacean/util/credentials.py | 1 + tools/model-generation/generate_models.py | 1 + tools/model-generation/spec/__init__.py | 1 + 11 files changed, 123 insertions(+), 128 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cd72f4d5..8bab3321 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,14 +12,14 @@ repos: - id: trailing-whitespace args: [--markdown-linebreak-ext=md] - repo: https://github.com/kynan/nbstripout - rev: 0.6.0 + rev: 0.7.1 hooks: - id: nbstripout types: ["jupyter"] args: ["--drop-empty-cells", "--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'"] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.2.0 + rev: v0.3.7 hooks: - id: ruff-format types_or: [ python, pyi ] diff --git a/docs/user-guide/downloading.ipynb b/docs/user-guide/downloading.ipynb index b7a84b51..812a2884 100644 --- a/docs/user-guide/downloading.ipynb +++ b/docs/user-guide/downloading.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "594ba90e-8388-434c-8d33-c9001f64b6c8", + "id": "0", "metadata": {}, "source": [ "# Downloading datasets\n", @@ -54,7 +54,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22f329e2-624f-4406-93d4-55913e83624d", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -64,7 +64,7 @@ }, { "cell_type": "markdown", - "id": "4e8aea34-fb1f-469c-b2d6-c7d64880b7da", + "id": "2", "metadata": {}, "source": [ "## Metadata\n", @@ -77,7 +77,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9388ae93-2b8a-4388-8451-26dd263345d8", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -86,7 +86,7 @@ }, { "cell_type": "markdown", - "id": "29dbb19b-a46e-4140-ae59-9f41ddf86340", + "id": "4", "metadata": {}, "source": [ "Datasets can easily be inspected in Jupyter notebooks:" @@ -95,7 +95,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c4ca91c2-2c51-4dee-906e-4c97c0b7a1e7", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -104,7 +104,7 @@ }, { "cell_type": "markdown", - "id": "08363dcc-4a11-40b6-af47-8c6096754868", + "id": "6", "metadata": {}, "source": [ "All attributes listed above can be accessed directly:" @@ -113,7 +113,7 @@ { "cell_type": "code", "execution_count": null, - "id": "26d06a21-8cc7-4364-b289-37041f455d9c", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -123,7 +123,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d78b40ef-4494-49a8-ae2f-233188ba52eb", + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -133,7 +133,7 @@ { "cell_type": "code", "execution_count": null, - "id": "bd441bbd-58f7-47bf-ac14-edd730c05ab4", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -142,7 +142,7 @@ }, { "cell_type": "markdown", - "id": "b8ddc42b-b43d-4f95-b40a-235af77d9d27", + "id": "10", "metadata": {}, "source": [ "See [Dataset](../generated/classes/scitacean.Dataset.rst) for a list of available fields.\n", @@ -153,7 +153,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c7788a40-0d56-442c-ad19-6fe5205bc476", + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -162,7 +162,7 @@ }, { "cell_type": "markdown", - "id": "020840e2-9291-4d1c-b8e1-b25709fcf790", + "id": "12", "metadata": {}, "source": [ "## Files\n", @@ -173,7 +173,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2fcb8261-ff87-4788-adbd-6e6fd7a9d2f1", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ }, { "cell_type": "markdown", - "id": "c5fb8c86-ccf7-4245-99da-b5b49dce4c5d", + "id": "14", "metadata": {}, "source": [ "Note that the `local_path` for both files is `None`.\n", @@ -199,7 +199,7 @@ { "cell_type": "code", "execution_count": null, - "id": "39f3e892-919c-495b-ad9a-37c6ca46aafb", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -209,7 +209,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dfe6545b-4c3b-4998-9831-aece5c3bb116", + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -222,7 +222,7 @@ }, { "cell_type": "markdown", - "id": "0097c9f9-ff98-4bd2-971f-70fd1001d186", + "id": "17", "metadata": {}, "source": [ "Which populates the `local_path`:" @@ -231,7 +231,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cc9fec2d-51e8-462f-9c1d-e510ec2eefbf", + "id": "18", "metadata": {}, "outputs": [], "source": [ @@ -241,7 +241,7 @@ { "cell_type": "code", "execution_count": null, - "id": "84f086f8-e930-4ccb-ad22-5b5e0bb0cc6e", + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -250,7 +250,7 @@ }, { "cell_type": "markdown", - "id": "28a14e32-f2fa-45d4-9b62-2c6f04abeffb", + "id": "20", "metadata": {}, "source": [ "We can use it to read the file:" @@ -259,7 +259,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7b1ffde0-e2b9-47ff-ac68-3d327a18c124", + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -269,7 +269,7 @@ }, { "cell_type": "markdown", - "id": "1492ed89-a0e0-46c2-b24a-7e621f230b20", + "id": "22", "metadata": {}, "source": [ "If we wanted to download all files, we could pass `select=True` (or nothing, `True` is the default) to `client.download_files`.\n", @@ -279,7 +279,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eee2b6c2-8f6f-447e-a392-e5dc84eab6cc", + "id": "23", "metadata": { "nbsphinx": "hidden", "tags": [] diff --git a/docs/user-guide/testing.ipynb b/docs/user-guide/testing.ipynb index a45ef168..4547bf1b 100644 --- a/docs/user-guide/testing.ipynb +++ b/docs/user-guide/testing.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "955a4d05-166f-4456-8dac-f81d0e40805a", + "id": "0", "metadata": { "tags": [] }, @@ -26,7 +26,7 @@ { "cell_type": "code", "execution_count": null, - "id": "53ae8816-eea4-49f4-a0d0-20d037f3d1e5", + "id": "1", "metadata": { "tags": [] }, @@ -49,7 +49,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e7ff9e70-9d75-4e15-b0ad-ccddc02741fd", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -64,7 +64,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e7985c81-0df3-4f18-a417-8d5ed8afd5ee", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -73,7 +73,7 @@ }, { "cell_type": "markdown", - "id": "94eace31-d349-40e6-8942-1ceea4830f0f", + "id": "4", "metadata": { "tags": [] }, @@ -90,7 +90,7 @@ { "cell_type": "code", "execution_count": null, - "id": "59eae44f-46a6-4a07-98cc-81104a25503b", + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -104,7 +104,7 @@ }, { "cell_type": "markdown", - "id": "e566a6bd-e7e1-4c0b-bb80-c92bcc1b30ba", + "id": "6", "metadata": {}, "source": [ "### Upload\n", @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "06e47461-c6c8-456f-ac04-10541fbe8907", + "id": "7", "metadata": {}, "outputs": [], "source": [ @@ -125,7 +125,7 @@ }, { "cell_type": "markdown", - "id": "d882e803-0609-4940-8033-788d0b735b20", + "id": "8", "metadata": {}, "source": [ "However, this did not talk to a SciCat server.\n", @@ -136,7 +136,7 @@ { "cell_type": "code", "execution_count": null, - "id": "22860c6e-b880-4baf-8709-e80fb8d5781a", + "id": "9", "metadata": {}, "outputs": [], "source": [ @@ -146,7 +146,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8d0bcbe-48d6-41f1-95fc-7c39426c3cfb", + "id": "10", "metadata": {}, "outputs": [], "source": [ @@ -156,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "25c2ddd3-0105-4370-b57e-65ac94e67b28", + "id": "11", "metadata": {}, "source": [ "The client has recorded the upload from earlier.\n", @@ -167,7 +167,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b9538f81-18d6-4441-9c09-b8dc4c8c1c71", + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -177,7 +177,7 @@ { "cell_type": "code", "execution_count": null, - "id": "05633fd9-1286-40f4-91ca-4e8c1a2df299", + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -187,7 +187,7 @@ }, { "cell_type": "markdown", - "id": "792d672e-325e-4b5b-80d7-4c71baa6c71d", + "id": "14", "metadata": {}, "source": [ "When writing tests, those recorded dataset and datablock models can be used to check if an upload worked.\n", @@ -200,7 +200,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d2e9d67d-8ae1-4462-8035-1907bb3a98fc", + "id": "15", "metadata": {}, "outputs": [], "source": [ @@ -210,7 +210,7 @@ }, { "cell_type": "markdown", - "id": "2919ab29-8d74-416d-b611-d1f1b5ba8fdb", + "id": "16", "metadata": {}, "source": [ "This is now an actual `Dataset` object like you would get from a real client.\n", @@ -232,7 +232,7 @@ }, { "cell_type": "markdown", - "id": "da104640-ce5f-4e04-81fd-878167b8bd08", + "id": "17", "metadata": {}, "source": [ "## FakeFileTransfer\n", @@ -246,7 +246,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7457b8a6-b067-443d-adda-88cc97af22f5", + "id": "18", "metadata": { "tags": [] }, @@ -262,7 +262,7 @@ }, { "cell_type": "markdown", - "id": "15d15535-78c1-440f-b50e-626ea5457cd0", + "id": "19", "metadata": {}, "source": [ "And upload a dataset:" @@ -271,7 +271,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9e74e0fe-225a-4899-908c-e24002ad1a0c", + "id": "20", "metadata": { "tags": [] }, @@ -282,7 +282,7 @@ }, { "cell_type": "markdown", - "id": "09f3c366-74ef-41bc-82ca-188cfdd240a3", + "id": "21", "metadata": {}, "source": [ "The file transfer has recorded the upload of the file without actually uploading it anywhere.\n", @@ -292,7 +292,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e015c1f5-1f6b-4289-b6a5-435bcdf02512", + "id": "22", "metadata": { "tags": [] }, @@ -303,7 +303,7 @@ }, { "cell_type": "markdown", - "id": "a1b67454-e63c-42d1-85a9-f1b16d0219c8", + "id": "23", "metadata": {}, "source": [ "This is a dictionary keyed by [remote_access_path](../generated/classes/scitacean.File.rst#scitacean.File.remote_access_path) to the content of the file.\n", @@ -314,7 +314,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cc713b35-29d5-4a36-a51b-c3f437e8e4f7", + "id": "24", "metadata": { "tags": [] }, @@ -327,7 +327,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ce5bd08a-9399-4c3b-9a92-ea5ae733e29a", + "id": "25", "metadata": { "tags": [] }, @@ -340,7 +340,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d3135347-569b-49c2-8726-e65cdc07ac0b", + "id": "26", "metadata": { "tags": [] }, @@ -352,7 +352,7 @@ }, { "cell_type": "markdown", - "id": "2489a7d3-4f49-4112-b68b-96a96f8733e4", + "id": "27", "metadata": {}, "source": [ "If we want to test downloads independently of uploads, we can populate `client.file_transfer.files` manually." @@ -360,7 +360,7 @@ }, { "cell_type": "markdown", - "id": "7fc127dd-5ab3-4df6-a971-65a883d4afc2", + "id": "28", "metadata": {}, "source": [ "## Local SciCat server\n", @@ -388,7 +388,7 @@ { "cell_type": "code", "execution_count": null, - "id": "778c07f6-199c-4e46-a66e-0196f4fbdbd4", + "id": "29", "metadata": { "tags": [] }, @@ -408,7 +408,7 @@ }, { "cell_type": "markdown", - "id": "630a84a8-abef-4fda-b4dc-efeeaacf2043", + "id": "30", "metadata": {}, "source": [ "The backend will only be launched when the corresponding command line option is given.\n", @@ -422,7 +422,7 @@ { "cell_type": "code", "execution_count": null, - "id": "cb966da1-46c8-4a8b-ab49-2930e1bf4c3a", + "id": "31", "metadata": { "tags": [] }, @@ -435,7 +435,7 @@ }, { "cell_type": "markdown", - "id": "6095c70a-4b02-456a-a64c-54bf96278695", + "id": "32", "metadata": {}, "source": [ "The `require_scicat_backend` fixture will ensure that the backend is running during the test.\n", @@ -447,7 +447,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ef74ea13-c110-4087-b0f8-e5770a7e13b3", + "id": "33", "metadata": {}, "outputs": [], "source": [ @@ -458,7 +458,7 @@ }, { "cell_type": "markdown", - "id": "30560dea-7d42-4d5a-a259-d8c1415efb05", + "id": "34", "metadata": {}, "source": [ "The `client` fixture provides both a client connected to the SciCat server and a fake client.\n", @@ -474,7 +474,7 @@ { "cell_type": "code", "execution_count": null, - "id": "070daa80-8cc7-4e4f-97ac-74a383e0c023", + "id": "35", "metadata": {}, "outputs": [], "source": [ @@ -488,7 +488,7 @@ }, { "cell_type": "markdown", - "id": "a3e4ec61-e127-4ce4-81a3-0781521b73d6", + "id": "36", "metadata": {}, "source": [ "### Seed data\n", @@ -502,7 +502,7 @@ { "cell_type": "code", "execution_count": null, - "id": "432b8c32-7ecf-4638-b364-5ec98cc40ce1", + "id": "37", "metadata": {}, "outputs": [], "source": [ @@ -516,7 +516,7 @@ }, { "cell_type": "markdown", - "id": "cc6f9f5f-884a-4986-baba-654cb0fd941c", + "id": "38", "metadata": {}, "source": [ "Both clients, i.e., also the fake client, require that the database has been seeded, even when backend tests are disabled.\n", @@ -527,7 +527,7 @@ { "cell_type": "code", "execution_count": null, - "id": "fc260196-0ade-4773-8bad-b53a1a6740f2", + "id": "39", "metadata": {}, "outputs": [], "source": [ @@ -539,7 +539,7 @@ }, { "cell_type": "markdown", - "id": "e67d6111-9589-403e-a7ad-6f35b5d82db4", + "id": "40", "metadata": {}, "source": [ "This will run the test both when backend tests are enabled and disabled.\n", @@ -551,7 +551,7 @@ }, { "cell_type": "markdown", - "id": "97930d15-517a-4cea-bf2b-38ed700220b3", + "id": "41", "metadata": {}, "source": [ "## Local SFTP fileserver\n", @@ -579,7 +579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d1f763b-1f56-4574-a7d5-5d77e85b888d", + "id": "42", "metadata": {}, "outputs": [], "source": [ @@ -597,7 +597,7 @@ }, { "cell_type": "markdown", - "id": "0d92f3dd-986c-4f2c-acec-00b6e55ae87b", + "id": "43", "metadata": {}, "source": [ "The SFTP server will only be launched when the corresponding command line option is given.\n", @@ -611,7 +611,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8e63fde0-827e-4fd5-b55f-980843253813", + "id": "44", "metadata": {}, "outputs": [], "source": [ @@ -622,7 +622,7 @@ }, { "cell_type": "markdown", - "id": "3126d0d9-727a-4d55-aff1-6b31fd5df91f", + "id": "45", "metadata": {}, "source": [ "The `require_sftp_fileserver` fixture will ensure that the SFTP server is running during the test.\n", @@ -637,7 +637,7 @@ { "cell_type": "code", "execution_count": null, - "id": "599b4199-ff30-4899-ab22-0af2b504ecae", + "id": "46", "metadata": {}, "outputs": [], "source": [ @@ -662,7 +662,7 @@ }, { "cell_type": "markdown", - "id": "c083ed37-0c9d-425a-bce3-a2ad44b47a43", + "id": "47", "metadata": {}, "source": [ "Uploaded files are readable on the host.\n", @@ -682,7 +682,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a811256e-db50-450b-839c-fe9eb2e45c57", + "id": "48", "metadata": { "nbsphinx": "hidden", "tags": [] diff --git a/docs/user-guide/uploading.ipynb b/docs/user-guide/uploading.ipynb index ab05165c..4df67aac 100644 --- a/docs/user-guide/uploading.ipynb +++ b/docs/user-guide/uploading.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "e1d98ec6-9bab-4a7e-b75c-8defc9d184d0", + "id": "0", "metadata": {}, "source": [ "# Uploading datasets\n", @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "78fec2b3-b03b-4711-b10b-48c5b9ab78e6", + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -37,7 +37,7 @@ }, { "cell_type": "markdown", - "id": "a1c15f19-f83f-4fda-a83c-59ece80b81f8", + "id": "2", "metadata": {}, "source": [ "This is especially useful here as datasets cannot be deleted from SciCat by regular users, and we don't want to pollute the database with our test data.\n", @@ -48,7 +48,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9f32e0e2-e5b1-4a61-b7fa-07f495a8db99", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ }, { "cell_type": "markdown", - "id": "acbcc0a4-fc75-4555-8665-a2bf4fb9c498", + "id": "4", "metadata": {}, "source": [ "## Create a new dataset\n", @@ -73,7 +73,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d85b8c79-9a4f-4c3b-bf20-e1b1bd4ccdab", + "id": "5", "metadata": { "tags": [] }, @@ -101,7 +101,7 @@ }, { "cell_type": "markdown", - "id": "53bfee0c-82b3-4e2f-ad4b-929ea7df6519", + "id": "6", "metadata": {}, "source": [ "There are many more fields that can be filled in as needed.\n", @@ -118,7 +118,7 @@ { "cell_type": "code", "execution_count": null, - "id": "01e303db-0e94-450a-acce-3ab48d034bb3", + "id": "7", "metadata": { "tags": [] }, @@ -129,7 +129,7 @@ }, { "cell_type": "markdown", - "id": "21d4bdcf-3cd4-4aea-898d-fa8713c48ff4", + "id": "8", "metadata": {}, "source": [ "Setting the `base_path` to `\"data\"` means that the file will be uploaded to `source_folder/withcraft.dat` where `source_folder` will be determined by the file transfer.\n", @@ -142,7 +142,7 @@ { "cell_type": "code", "execution_count": null, - "id": "27ea91e9-5d9d-4856-b452-b20d3b3009da", + "id": "9", "metadata": { "tags": [] }, @@ -154,7 +154,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1c1c11a1-c29d-4c92-9efc-d120d5bf2582", + "id": "10", "metadata": { "tags": [] }, @@ -166,7 +166,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d0763ba4-5fa4-4db8-b7ac-ed225efd3993", + "id": "11", "metadata": { "tags": [] }, @@ -178,7 +178,7 @@ { "cell_type": "code", "execution_count": null, - "id": "249c1e79-40be-4e2c-bfa2-8b662604ede0", + "id": "12", "metadata": { "tags": [] }, @@ -192,7 +192,7 @@ }, { "cell_type": "markdown", - "id": "38938be4-382d-4025-bbe1-19804cd13d8e", + "id": "13", "metadata": {}, "source": [ "The file has a `local_path` but no `remote_access_path` which means that it exists on the local file system (where we put it earlier) but not on the remote file server accessible by SciCat.\n", @@ -210,7 +210,7 @@ { "cell_type": "code", "execution_count": null, - "id": "46ac5ffe-c544-49b4-baf2-a71b3008f5af", + "id": "14", "metadata": { "tags": [] }, @@ -221,7 +221,7 @@ }, { "cell_type": "markdown", - "id": "b4dcd592-8228-436f-8969-05f2627cc473", + "id": "15", "metadata": {}, "source": [ "
\n", @@ -242,7 +242,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e98e4339-970b-4b0b-9d3c-2dd03b9794c2", + "id": "16", "metadata": { "tags": [] }, @@ -253,7 +253,7 @@ }, { "cell_type": "markdown", - "id": "19d91fd6-0f6a-4bb3-9d9e-f71295623352", + "id": "17", "metadata": {}, "source": [ "And the remote access path of our file has been set:" @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6c6d3650-410c-4ab6-9f56-fcd5290c8004", + "id": "18", "metadata": { "tags": [] }, @@ -273,7 +273,7 @@ }, { "cell_type": "markdown", - "id": "5d5cd1c0-97fc-4931-acba-f2bea3ab1d7c", + "id": "19", "metadata": {}, "source": [ "## Location of uploaded files\n", @@ -291,7 +291,7 @@ { "cell_type": "code", "execution_count": null, - "id": "71beba39-b330-4251-bc2a-5584eb246fb2", + "id": "20", "metadata": { "tags": [] }, @@ -302,7 +302,7 @@ }, { "cell_type": "markdown", - "id": "95201e00-8119-4c34-9fe5-2d2bb58d826d", + "id": "21", "metadata": {}, "source": [ "Or by looking at each file individually as shown in the section above." @@ -310,7 +310,7 @@ }, { "cell_type": "markdown", - "id": "ebbfc735-e8eb-4ceb-b5fb-ca252dd9ee6f", + "id": "22", "metadata": {}, "source": [ "## Attaching images to datasets\n", @@ -324,7 +324,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5f15eedf-ab14-4f1b-8659-d8f62c6975bc", + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -342,7 +342,7 @@ }, { "cell_type": "markdown", - "id": "986b6271-4faf-4b2c-9283-872f6fdf8281", + "id": "24", "metadata": {}, "source": [ "We used `Thumbnail.load_file` because it properly encodes the file for SciCat.\n", @@ -355,7 +355,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f82de9eb-2a34-436c-8694-1a13af82cb66", + "id": "25", "metadata": {}, "outputs": [], "source": [ @@ -364,7 +364,7 @@ }, { "cell_type": "markdown", - "id": "7f686546-da06-4c15-b357-b44da8bfc328", + "id": "26", "metadata": {}, "source": [ "In order to download the attachments again, we can pass `attachments=True` when downloading the dataset:" @@ -373,7 +373,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b8a673c7-20b2-4e0e-a003-016227821651", + "id": "27", "metadata": {}, "outputs": [], "source": [ @@ -384,7 +384,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d8dbbd21-81a6-4610-965a-5e23446d593f", + "id": "28", "metadata": { "nbsphinx": "hidden", "tags": [] diff --git a/pyproject.toml b/pyproject.toml index 778fe98b..05ee53c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -100,6 +100,10 @@ warn_required_dynamic_aliases = true [tool.ruff] line-length = 88 +extend-include = ["*.ipynb"] +extend-exclude = [".*", "__pycache__", "build", "dist", "venv"] + +[tool.ruff.lint] select = ["B", "D", "E", "F", "G", "I", "S", "T20", "PGH", "FBT003", "RUF"] ignore = [ "B905", # `zip()` without an explicit `strict=` parameter @@ -108,11 +112,11 @@ ignore = [ "E111", "E114", "E117", "D206", "D300", # conflict with ruff format "D105", ] -extend-include = ["*.ipynb"] -extend-exclude = [".*", "__pycache__", "build", "dist", "venv"] fixable = ["I001"] +isort.known-first-party = ["scitacean"] +pydocstyle.convention = "numpy" -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "tests/*" = [ "S101", # asserts are fine in tests "D10", # no docstrings required in tests @@ -126,14 +130,5 @@ fixable = ["I001"] "src/scitacean/model.py" = ["D10"] "src/scitacean/testing/strategies.py" = ["D401"] -[tool.ruff.isort] -known-first-party = ["scitacean"] - -[tool.ruff.pydocstyle] -convention = "numpy" - -#[tool.ruff.format] -#docstring-code-format = false - [tool.codespell] ignore-words-list = "specfield" diff --git a/src/scitacean/_base_model.py b/src/scitacean/_base_model.py index 2a711565..c8838524 100644 --- a/src/scitacean/_base_model.py +++ b/src/scitacean/_base_model.py @@ -2,6 +2,7 @@ # Copyright (c) 2024 SciCat Project (https://github.com/SciCatProject/scitacean) """Types and functions to implement models for communication with SciCat.""" + from __future__ import annotations import dataclasses @@ -267,20 +268,17 @@ def validate_orcids(value: Optional[str]) -> Optional[str]: @overload -def convert_download_to_user_model(download_model: None) -> None: - ... +def convert_download_to_user_model(download_model: None) -> None: ... @overload -def convert_download_to_user_model(download_model: BaseModel) -> BaseUserModel: - ... +def convert_download_to_user_model(download_model: BaseModel) -> BaseUserModel: ... @overload def convert_download_to_user_model( download_model: Iterable[BaseModel], -) -> List[BaseUserModel]: - ... +) -> List[BaseUserModel]: ... def convert_download_to_user_model( @@ -297,20 +295,17 @@ def convert_download_to_user_model( @overload -def convert_user_to_upload_model(user_model: None) -> None: - ... +def convert_user_to_upload_model(user_model: None) -> None: ... @overload -def convert_user_to_upload_model(user_model: BaseUserModel) -> BaseModel: - ... +def convert_user_to_upload_model(user_model: BaseUserModel) -> BaseModel: ... @overload def convert_user_to_upload_model( user_model: Iterable[BaseUserModel], -) -> List[BaseModel]: - ... +) -> List[BaseModel]: ... def convert_user_to_upload_model( diff --git a/src/scitacean/_html_repr/__init__.py b/src/scitacean/_html_repr/__init__.py index 99d9e7a2..826dc8f4 100644 --- a/src/scitacean/_html_repr/__init__.py +++ b/src/scitacean/_html_repr/__init__.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2024 SciCat Project (https://github.com/SciCatProject/scitacean) """HTML representations for Jupyter.""" + from __future__ import annotations from functools import lru_cache diff --git a/src/scitacean/_internal/docker.py b/src/scitacean/_internal/docker.py index 847bc241..009ba5c9 100644 --- a/src/scitacean/_internal/docker.py +++ b/src/scitacean/_internal/docker.py @@ -5,6 +5,7 @@ Primarily meant for testing. """ + import json import os import subprocess diff --git a/src/scitacean/util/credentials.py b/src/scitacean/util/credentials.py index 641944f9..10ae8bc4 100644 --- a/src/scitacean/util/credentials.py +++ b/src/scitacean/util/credentials.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2024 SciCat Project (https://github.com/SciCatProject/scitacean) """Tools for securely handling credentials.""" + from __future__ import annotations import datetime diff --git a/tools/model-generation/generate_models.py b/tools/model-generation/generate_models.py index c7c35aac..2bf29cf6 100644 --- a/tools/model-generation/generate_models.py +++ b/tools/model-generation/generate_models.py @@ -2,6 +2,7 @@ # Copyright (c) 2024 SciCat Project (https://github.com/SciCatProject/scitacean) """Generate Python classes for SciCat models.""" + import argparse import subprocess import tempfile diff --git a/tools/model-generation/spec/__init__.py b/tools/model-generation/spec/__init__.py index ca4f7a04..99f6ce5f 100644 --- a/tools/model-generation/spec/__init__.py +++ b/tools/model-generation/spec/__init__.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2024 SciCat Project (https://github.com/SciCatProject/scitacean) """Load model specifications.""" + import dataclasses import re import sys From e8008378e0648a386117fe6f194aef97326bbd0e Mon Sep 17 00:00:00 2001 From: Jan-Lukas Wynen Date: Fri, 12 Apr 2024 14:10:54 +0200 Subject: [PATCH 2/3] Update GH actions --- .github/workflows/ci.yml | 10 +++++----- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/docs.yml | 6 +++--- .github/workflows/release.yml | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6eb82f6f..c0a2ffc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,8 @@ jobs: name: Formatting and static analysis runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - run: python -m pip install --upgrade pip - run: python -m pip install -r requirements/ci.txt - run: tox -e static @@ -27,7 +27,7 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.11 - run: python -m pip install --upgrade pip @@ -50,8 +50,8 @@ jobs: steps: - run: sudo apt install --yes docker-compose if: ${{ contains(matrix.variant.os, 'ubuntu') }} - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - run: python -m pip install --upgrade pip diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 3e5b1ac8..cfd39b3e 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ed167d73..347e960f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -21,15 +21,15 @@ jobs: runs-on: ubuntu-22.04 steps: - run: sudo apt install --yes pandoc - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: python-version: 3.11 - run: python -m pip install --upgrade pip - run: python -m pip install -r requirements/ci.txt - run: tox -e docs - run: touch html/.nojekyll - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: documentation path: html/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d02e4be3..0a3e7cf4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,8 +10,8 @@ jobs: name: Check if package can be released runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-python@v4 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 - run: python -m pip install --upgrade pip - run: python -m pip install -r requirements/ci.txt - run: tox -e check-release @@ -22,11 +22,11 @@ jobs: runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 # history required so setuptools_scm can determine version - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 - run: python -m pip install --upgrade pip - run: python -m pip install -r requirements/wheels.txt @@ -34,7 +34,7 @@ jobs: run: python -m build - name: Upload wheels - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: dist path: dist @@ -49,7 +49,7 @@ jobs: if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v2 + - uses: actions/download-artifact@v4 - uses: pypa/gh-action-pypi-publish@v1.8.14 docs: From 92506830c150c0aaf4294aad95e75a95efc1ddea Mon Sep 17 00:00:00 2001 From: Jan-Lukas Wynen Date: Fri, 12 Apr 2024 14:18:10 +0200 Subject: [PATCH 3/3] Update dependencies --- requirements/base.txt | 18 +++++++++--------- requirements/ci.txt | 10 +++++----- requirements/dev.txt | 36 ++++++++++++++++++------------------ requirements/docs.txt | 32 ++++++++++++++++---------------- requirements/mypy.txt | 12 ++++++------ requirements/static.txt | 8 ++++---- requirements/test.txt | 12 ++++++------ requirements/wheels.txt | 4 ++-- 8 files changed, 66 insertions(+), 66 deletions(-) diff --git a/requirements/base.txt b/requirements/base.txt index 403adc94..7bdf5195 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -17,15 +17,15 @@ cffi==1.16.0 # pynacl charset-normalizer==3.3.2 # via requests -cryptography==42.0.4 +cryptography==42.0.5 # via paramiko decorator==5.1.1 # via fabric deprecated==1.2.14 # via fabric -dnspython==2.5.0 +dnspython==2.6.1 # via email-validator -email-validator==2.1.0.post1 +email-validator==2.1.1 # via -r base.in fabric==3.2.2 # via -r base.in @@ -39,25 +39,25 @@ paramiko==3.4.0 # via # -r base.in # fabric -pycparser==2.21 +pycparser==2.22 # via cffi -pydantic==2.6.1 +pydantic==2.7.0 # via -r base.in -pydantic-core==2.16.2 +pydantic-core==2.18.1 # via pydantic pynacl==1.5.0 # via paramiko -python-dateutil==2.8.2 +python-dateutil==2.9.0.post0 # via -r base.in requests==2.31.0 # via -r base.in six==1.16.0 # via python-dateutil -typing-extensions==4.9.0 +typing-extensions==4.11.0 # via # pydantic # pydantic-core -urllib3==2.2.0 +urllib3==2.2.1 # via requests wrapt==1.16.0 # via deprecated diff --git a/requirements/ci.txt b/requirements/ci.txt index b576beb3..e8ef0de6 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -5,7 +5,7 @@ # # pip-compile-multi # -cachetools==5.3.2 +cachetools==5.3.3 # via tox chardet==5.2.0 # via tox @@ -13,11 +13,11 @@ colorama==0.4.6 # via tox distlib==0.3.8 # via virtualenv -filelock==3.13.1 +filelock==3.13.4 # via # tox # virtualenv -packaging==23.2 +packaging==24.0 # via # pyproject-api # tox @@ -29,7 +29,7 @@ pluggy==1.4.0 # via tox pyproject-api==1.6.1 # via tox -tox==4.12.1 +tox==4.14.2 # via -r ci.in -virtualenv==20.25.0 +virtualenv==20.25.1 # via tox diff --git a/requirements/dev.txt b/requirements/dev.txt index f28ada32..3e098f5a 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -12,7 +12,7 @@ -r static.txt -r test.txt -r wheels.txt -anyio==4.2.0 +anyio==4.3.0 # via # httpx # jupyter-server @@ -32,13 +32,13 @@ fqdn==1.5.1 # via jsonschema h11==0.14.0 # via httpcore -httpcore==1.0.2 +httpcore==1.0.5 # via httpx -httpx==0.26.0 +httpx==0.27.0 # via jupyterlab isoduration==20.11.0 # via jsonschema -json5==0.9.14 +json5==0.9.24 # via jupyterlab-server jsonpointer==2.4 # via jsonschema @@ -47,31 +47,31 @@ jsonschema[format-nongpl]==4.21.1 # jupyter-events # jupyterlab-server # nbformat -jupyter-events==0.9.0 +jupyter-events==0.10.0 # via jupyter-server -jupyter-lsp==2.2.2 +jupyter-lsp==2.2.5 # via jupyterlab -jupyter-server==2.12.5 +jupyter-server==2.14.0 # via # jupyter-lsp # jupyterlab # jupyterlab-server # notebook-shim -jupyter-server-terminals==0.5.2 +jupyter-server-terminals==0.5.3 # via jupyter-server -jupyterlab==4.1.0 +jupyterlab==4.1.6 # via -r dev.in -jupyterlab-server==2.25.2 +jupyterlab-server==2.26.0 # via jupyterlab -notebook-shim==0.2.3 +notebook-shim==0.2.4 # via jupyterlab overrides==7.7.0 # via jupyter-server pip-compile-multi==2.6.3 # via -r dev.in -pip-tools==7.3.0 +pip-tools==7.4.1 # via pip-compile-multi -prometheus-client==0.19.0 +prometheus-client==0.20.0 # via jupyter-server python-json-logger==2.0.7 # via jupyter-events @@ -83,15 +83,15 @@ rfc3986-validator==0.1.1 # via # jsonschema # jupyter-events -ruff==0.2.1 +ruff==0.3.7 # via -r dev.in -send2trash==1.8.2 +send2trash==1.8.3 # via jupyter-server -sniffio==1.3.0 +sniffio==1.3.1 # via # anyio # httpx -terminado==0.18.0 +terminado==0.18.1 # via # jupyter-server # jupyter-server-terminals @@ -103,7 +103,7 @@ webcolors==1.13 # via jsonschema websocket-client==1.7.0 # via jupyter-server -wheel==0.42.0 +wheel==0.43.0 # via pip-tools # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/docs.txt b/requirements/docs.txt index 0430125e..2d1ee954 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -13,7 +13,7 @@ alabaster==0.7.16 # via sphinx asttokens==2.4.1 # via stack-data -autodoc-pydantic==2.0.1 +autodoc-pydantic==2.1.0 # via -r docs.in babel==2.14.0 # via @@ -25,9 +25,9 @@ beautifulsoup4==4.12.3 # pydata-sphinx-theme bleach==6.1.0 # via nbconvert -comm==0.2.1 +comm==0.2.2 # via ipykernel -debugpy==1.8.0 +debugpy==1.8.1 # via ipykernel defusedxml==0.7.1 # via nbconvert @@ -43,9 +43,9 @@ fastjsonschema==2.19.1 # via nbformat imagesize==1.4.1 # via sphinx -ipykernel==6.29.1 +ipykernel==6.29.4 # via -r docs.in -ipython==8.21.0 +ipython==8.23.0 # via # -r docs.in # ipykernel @@ -61,11 +61,11 @@ jsonschema==4.21.1 # via nbformat jsonschema-specifications==2023.12.1 # via jsonschema -jupyter-client==8.6.0 +jupyter-client==8.6.1 # via # ipykernel # nbclient -jupyter-core==5.7.1 +jupyter-core==5.7.2 # via # ipykernel # jupyter-client @@ -94,11 +94,11 @@ mistune==3.0.2 # via nbconvert myst-parser==2.0.0 # via -r docs.in -nbclient==0.9.0 +nbclient==0.10.0 # via nbconvert -nbconvert==7.15.0 +nbconvert==7.16.3 # via nbsphinx -nbformat==5.9.2 +nbformat==5.10.4 # via # nbclient # nbconvert @@ -109,7 +109,7 @@ nest-asyncio==1.6.0 # via ipykernel pandocfilters==1.5.1 # via nbconvert -parso==0.8.3 +parso==0.8.4 # via jedi pexpect==4.9.0 # via ipython @@ -123,7 +123,7 @@ ptyprocess==0.7.0 # via pexpect pure-eval==0.2.2 # via stack-data -pydantic-settings==2.1.0 +pydantic-settings==2.2.1 # via autodoc-pydantic pydata-sphinx-theme==0.15.2 # via -r docs.in @@ -140,11 +140,11 @@ pyzmq==25.1.2 # via # ipykernel # jupyter-client -referencing==0.33.0 +referencing==0.34.0 # via # jsonschema # jsonschema-specifications -rpds-py==0.17.1 +rpds-py==0.18.0 # via # jsonschema # referencing @@ -162,7 +162,7 @@ sphinx==7.2.6 # sphinx-autodoc-typehints # sphinx-copybutton # sphinx-design -sphinx-autodoc-typehints==1.25.3 +sphinx-autodoc-typehints==2.0.1 # via -r docs.in sphinx-copybutton==0.5.2 # via -r docs.in @@ -188,7 +188,7 @@ tornado==6.4 # via # ipykernel # jupyter-client -traitlets==5.14.1 +traitlets==5.14.2 # via # comm # ipykernel diff --git a/requirements/mypy.txt b/requirements/mypy.txt index 94523f06..fcb370b1 100644 --- a/requirements/mypy.txt +++ b/requirements/mypy.txt @@ -6,17 +6,17 @@ # pip-compile-multi # -r test.txt -mypy==1.8.0 +mypy==1.9.0 # via -r mypy.in mypy-extensions==1.0.0 # via mypy -types-docutils==0.20.0.20240201 +types-docutils==0.20.0.20240406 # via -r mypy.in -types-paramiko==3.4.0.20240205 +types-paramiko==3.4.0.20240311 # via -r mypy.in -types-python-dateutil==2.8.19.20240106 +types-python-dateutil==2.9.0.20240316 # via -r mypy.in -types-pyyaml==6.0.12.12 +types-pyyaml==6.0.12.20240311 # via -r mypy.in -types-requests==2.31.0.20240125 +types-requests==2.31.0.20240406 # via -r mypy.in diff --git a/requirements/static.txt b/requirements/static.txt index 53c7664c..99028a0d 100644 --- a/requirements/static.txt +++ b/requirements/static.txt @@ -9,19 +9,19 @@ cfgv==3.4.0 # via pre-commit distlib==0.3.8 # via virtualenv -filelock==3.13.1 +filelock==3.13.4 # via virtualenv -identify==2.5.33 +identify==2.5.35 # via pre-commit nodeenv==1.8.0 # via pre-commit platformdirs==4.2.0 # via virtualenv -pre-commit==3.6.0 +pre-commit==3.7.0 # via -r static.in pyyaml==6.0.1 # via pre-commit -virtualenv==20.25.0 +virtualenv==20.25.1 # via pre-commit # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/test.txt b/requirements/test.txt index f8f3b3d5..4f6e8799 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -8,21 +8,21 @@ -r base.txt attrs==23.2.0 # via hypothesis -execnet==2.0.2 +execnet==2.1.1 # via pytest-xdist -filelock[typing]==3.13.1 +filelock[typing]==3.13.4 # via -r test.in -hypothesis==6.98.2 +hypothesis==6.100.1 # via -r test.in iniconfig==2.0.0 # via pytest -packaging==23.2 +packaging==24.0 # via pytest pluggy==1.4.0 # via pytest -pyfakefs==5.3.5 +pyfakefs==5.4.1 # via -r test.in -pytest==8.0.0 +pytest==8.1.1 # via # -r test.in # pytest-randomly diff --git a/requirements/wheels.txt b/requirements/wheels.txt index 22051eff..730ed229 100644 --- a/requirements/wheels.txt +++ b/requirements/wheels.txt @@ -5,9 +5,9 @@ # # pip-compile-multi # -build==1.0.3 +build==1.2.1 # via -r wheels.in -packaging==23.2 +packaging==24.0 # via build pyproject-hooks==1.0.0 # via build