Skip to content

Commit

Permalink
Fix unittests and notebooks
Browse files Browse the repository at this point in the history
Remove jupyterlab and use jupyter notebook instead

AB#9074
  • Loading branch information
eccles committed Feb 13, 2024
1 parent 59302cc commit 7720c08
Show file tree
Hide file tree
Showing 46 changed files with 70 additions and 45 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,28 @@ jobs:
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements-dev.txt
./scripts/version.sh
shell: bash
- name: Run integrity checks
- name: pycodestyle
run: |
./scripts/version.sh
pycodestyle --format=pylint archivist examples functests unittests
shell: bash
- name: pylint
run: |
python3 -m pylint archivist examples functests unittests
black archivist examples unittests functests
shell: bash
- name: black
run: |
modified=$(git status -s | wc -l)
black archivist examples unittests functests
if [ $modified -gt 0 ]
then
echo "there are $modified files that must be reformatted"
exit 1
fi
shell: bash
- name: unittests.sh
run: |
./scripts/unittests.sh
shell: bash
- name: Run type-hint checks
Expand Down
1 change: 1 addition & 0 deletions archivist/asset.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Asset data class
"""

from contextlib import suppress


Expand Down
1 change: 0 additions & 1 deletion archivist/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""


from copy import deepcopy
from logging import getLogger
from typing import TYPE_CHECKING, Any
Expand Down
1 change: 0 additions & 1 deletion archivist/compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""


from logging import getLogger
from typing import TYPE_CHECKING, Any

Expand Down
1 change: 0 additions & 1 deletion archivist/compliance_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"""


from copy import deepcopy
from logging import getLogger
from typing import TYPE_CHECKING, Any, Union
Expand Down
1 change: 0 additions & 1 deletion archivist/compliance_policy_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"""


from dataclasses import asdict, dataclass

from .compliance_policy_type import CompliancePolicyType
Expand Down
1 change: 0 additions & 1 deletion archivist/composite.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""


from logging import getLogger
from typing import TYPE_CHECKING

Expand Down
21 changes: 12 additions & 9 deletions archivist/confirmer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""assets confirmer interface
"""


from copy import deepcopy
from logging import getLogger
from typing import TYPE_CHECKING, Any, Union, overload
Expand Down Expand Up @@ -54,23 +53,27 @@ def __on_giveup_confirmation(details: "Details"):


@overload
def _wait_for_confirmation(self: "_AssetsRestricted", identity: str) -> "Asset":
... # pragma: no cover
def _wait_for_confirmation(
self: "_AssetsRestricted", identity: str
) -> "Asset": ... # pragma: no cover


@overload
def _wait_for_confirmation(self: "_AssetsPublic", identity: str) -> "Asset":
... # pragma: no cover
def _wait_for_confirmation(
self: "_AssetsPublic", identity: str
) -> "Asset": ... # pragma: no cover


@overload
def _wait_for_confirmation(self: "_EventsRestricted", identity: str) -> "Event":
... # pragma: no cover
def _wait_for_confirmation(
self: "_EventsRestricted", identity: str
) -> "Event": ... # pragma: no cover


@overload
def _wait_for_confirmation(self: "_EventsPublic", identity: str) -> "Event":
... # pragma: no cover
def _wait_for_confirmation(
self: "_EventsPublic", identity: str
) -> "Event": ... # pragma: no cover


@backoff.on_predicate(
Expand Down
1 change: 0 additions & 1 deletion archivist/dictmerge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Archivist dict deep merge
"""


from copy import deepcopy
from typing import Any

Expand Down
1 change: 0 additions & 1 deletion archivist/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"""


from copy import deepcopy
from logging import getLogger
from typing import TYPE_CHECKING, Any
Expand Down
1 change: 0 additions & 1 deletion archivist/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Manage headers allowing for upper/lower/canonicalize form
"""


from requests import models


Expand Down
1 change: 0 additions & 1 deletion archivist/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"""


from contextlib import suppress
from copy import deepcopy
from logging import getLogger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@
" # their arc_display_type.\n",
" # So a mistake here can result in asset data being\n",
" # under- or over-shared.\n",
" \"some_custom_attribute\": \"value\" # You can add any custom value as long as\n",
" \"some_custom_attribute\": \"value\", # You can add any custom value as long as\n",
" # it does not start with arc_\n",
" }\n",
" # The first argument is the attributes of the asset\n",
Expand Down
4 changes: 2 additions & 2 deletions archivist/notebooks/Initialization and Credentials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
],
"source": [
"# Install the datatrails-python package\n",
"%pip install --upgrade datatrails-archivist\n",
"%pip install --upgrade python-dotenv"
"%python3 -m pip install --upgrade datatrails-archivist\n",
"%python3 -m pip install --upgrade python-dotenv"
]
},
{
Expand Down
1 change: 0 additions & 1 deletion archivist/or_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Dictionaries where key is always 'or' and value is a list of strings
"""


from typing import Any


Expand Down
1 change: 0 additions & 1 deletion archivist/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""


from collections import defaultdict
from functools import partialmethod
from json import dumps as json_dumps
Expand Down
1 change: 0 additions & 1 deletion archivist/subjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""


from base64 import b64decode
from json import loads as json_loads
from logging import getLogger
Expand Down
1 change: 0 additions & 1 deletion archivist/subjects_confirmer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""assets confirmer interface
"""


from logging import getLogger
from typing import TYPE_CHECKING

Expand Down
1 change: 0 additions & 1 deletion archivist/tenancies.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"""


from logging import getLogger
from typing import TYPE_CHECKING

Expand Down
1 change: 0 additions & 1 deletion archivist/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Some convenience stuff
"""


from logging import getLogger
from typing import TYPE_CHECKING

Expand Down
5 changes: 3 additions & 2 deletions docs/notebooks/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#
# jupyter notebooks
ipython~=8.12
ipython~=8.12.3
notebook~=7.0.8
jupyter~=1.0
jupyterlab~=4.0
jupyter-console~=6.6
jupyter-contrib-nbextensions~=0.7
jupyter-nbextensions-configurator~=0.6
python-dotenv[cli]~=1.0

1 change: 1 addition & 0 deletions examples/access_policies_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
with suitable properties and attributes.
"""

from os import getenv
from warnings import filterwarnings

Expand Down
1 change: 1 addition & 0 deletions examples/compliance_policies_since.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
with suitable properties and attributes.
"""

from json import dumps as json_dumps
from os import getenv
from time import sleep
Expand Down
2 changes: 1 addition & 1 deletion examples/create_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_asset(arch):
# their arc_display_type.
# So a mistake here can result in asset data being
# under- or over-shared.
"some_custom_attribute": "value" # You can add any custom value as long as
"some_custom_attribute": "value", # You can add any custom value as long as
# it does not start with arc_
}
#
Expand Down
3 changes: 2 additions & 1 deletion examples/create_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
In both cases the verified domain name is displayed.
"""

from json import dumps as json_dumps
from os import getenv
from warnings import filterwarnings
Expand Down Expand Up @@ -112,7 +113,7 @@ def create_asset(arch):
# their arc_display_type.
# So a mistake here can result in asset data being
# under- or over-shared.
"some_custom_attribute": "value" # You can add any custom value as long as
"some_custom_attribute": "value", # You can add any custom value as long as
# it does not start with arc_
}
# The first argument is the attributes of the asset
Expand Down
1 change: 1 addition & 0 deletions examples/get_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
The main function would then call arch.assets.read_by_signature() to get one asset from
the instance.
"""

from os import getenv
from warnings import filterwarnings

Expand Down
1 change: 1 addition & 0 deletions examples/subject_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
'arch' is then called with arch.subjects.create_from_b64() and the subject will
be created.
"""

from os import getenv
from warnings import filterwarnings

Expand Down
1 change: 1 addition & 0 deletions examples/subjects_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
attributes.
"""

from os import getenv
from warnings import filterwarnings

Expand Down
1 change: 1 addition & 0 deletions functests/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
hide docstringss
"""

# pylint: disable=missing-docstring
import unittest

Expand Down
1 change: 1 addition & 0 deletions functests/execapplications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test applications
"""

from copy import deepcopy
from json import dumps as json_dumps
from os import getenv
Expand Down
1 change: 1 addition & 0 deletions functests/execattachments.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Tests the upload and download functionality of the SDK
"""

from contextlib import suppress
from filecmp import clear_cache, cmp
from io import BytesIO
Expand Down
1 change: 1 addition & 0 deletions functests/execcompliance_policies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test compliance policies
"""

from json import dumps as json_dumps
from os import getenv
from time import sleep
Expand Down
1 change: 1 addition & 0 deletions functests/execnotebooks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test subjects
"""

from os import getenv
from unittest import skip

Expand Down
1 change: 1 addition & 0 deletions functests/execsubjects.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Test subjects
"""

from json import dumps as json_dumps
from os import getenv
from uuid import uuid4
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ redefining-builtins-modules = ["six.moves", "past.builtins", "future.builtins",
# this will eventually be the de facto linter and pylint,pycodestyle etc will be removed.
# we can add a host of checkers in extend-select but for now lets keep it simple
[tool.ruff]
show-fixes = true
target-version = "py37"

[tool.ruff.lint]
extend-select = [
"C4",
"E",
Expand All @@ -571,7 +575,4 @@ extend-select = [
"TCH",
]
ignore = ["E501"]
show-fixes = true
target-version = "py37"


14 changes: 7 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

# code quality
autopep8~=2.0
black[jupyter]~=23.9
coverage[toml]~=7.3
pip-audit~=2.6
pycodestyle~=2.10
black[jupyter]~=24.1
coverage[toml]~=7.4
pip-audit~=2.7
pycodestyle~=2.11
pylint~=3.0
pyright~=1.1
ruff~=0.1
ruff~=0.2
unittest-xml-reporting~=3.2
testbook~=0.4
testbook~=0.3

# analyze dependencies
pipdeptree~=2.13

# uploading to pypi
build~=1.0
twine~=4.0
twine~=5.0

# for sbom.xml file
xq~=0.0
Expand Down
Loading

0 comments on commit 7720c08

Please sign in to comment.