Skip to content

Commit

Permalink
Merge branch 'main' into whatscookin/feat/vc-di-proof
Browse files Browse the repository at this point in the history
Signed-off-by: Emad <[email protected]>
  • Loading branch information
EmadAnwer authored Jul 7, 2024
2 parents 1034c80 + bfb0d7a commit d02441e
Show file tree
Hide file tree
Showing 225 changed files with 3,070 additions and 1,178 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.134.0/containers/python-3/.devcontainer/base.Dockerfile
ARG VARIANT="3.9"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
ARG VARIANT="3.12"
FROM mcr.microsoft.com/devcontainers/python:${VARIANT}

ARG POETRY_VERSION="1.4"
ENV POETRY_HOME="/opt/poetry" \
Expand Down
9 changes: 3 additions & 6 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
"dockerfile": "Dockerfile",
"context": "..",
"args": {
"VARIANT": "3.9-bullseye",
"VARIANT": "3.12-bullseye",
"POETRY_VERSION": "1.7.1"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.black-formatter",
"charliermarsh.ruff"
],
"settings": {
Expand All @@ -33,11 +32,9 @@
"source.fixAll": true,
"source.organizeImports": true
},
"editor.defaultFormatter": "ms-python.black-formatter",
"ruff.organizeImports": false
"editor.defaultFormatter": "charliermarsh.ruff",
"ruff.organizeImports": true
},
"black-formatter.importStrategy": "useBundled",
"black-formatter.showNotifications": "always",
"ruff.codeAction.fixViolation": {
"enable": true
},
Expand Down
3 changes: 0 additions & 3 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ WORKSPACE_DIR=$(pwd)
python -m pip install --upgrade pip
pip3 install -r demo/requirements.txt -r demo/requirements.behave.txt

# install black for formatting
pip3 install black

# install a version of aries-cloudagent so the pytests can pick up a version
pip3 install aries-cloudagent

Expand Down
20 changes: 0 additions & 20 deletions .github/workflows/blackformat.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Ruff Code Formatter and Linting Check

"on":
pull_request:
branches:
- main

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Ruff Format and Lint Check
uses: chartboost/ruff-action@v1
2 changes: 1 addition & 1 deletion .github/workflows/nigthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9", "3.10"]
python-version: ["3.12"]
if: github.repository == 'hyperledger/aries-cloudagent-python' || github.event_name == 'workflow_dispatch'
steps:
- name: checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ jobs:
- name: Tests
uses: ./.github/actions/run-unit-tests
with:
python-version: "3.9"
python-version: "3.12"
os: "ubuntu-latest"
is_pr: "true"
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9']
python-version: ['3.12']

name: Publish ACA-Py Image
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Tests
uses: ./.github/actions/run-unit-tests
with:
python-version: "3.9"
python-version: "3.12"
os: "ubuntu-latest"
is_pr: "false"
- name: Adjust Test Coverage Source
Expand Down
13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ repos:
stages: [commit-msg]
args: ["--config", ".commitlint.config.js"]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/psf/black
# Ensure this is synced with pyproject.toml
rev: 24.4.2
hooks:
- id: black
stages: [commit]
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ensure this is synced with pyproject.toml
rev: v0.4.4
rev: v0.5.0
hooks:
# Run the linter
- id: ruff
stages: [commit]
args: [--fix, --exit-non-zero-on-fix]
# Run the formatter
- id: ruff-format
stages: [commit]
args: [--fix, --exit-non-zero-on-fix, --formatter]
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: "ubuntu-20.04"
tools:
python: "3.9"
python: "3.12"

sphinx:
builder: dirhtml
Expand Down
47 changes: 16 additions & 31 deletions .vscode-sample/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
]
},
{
"name": "ruff - aries_cloudagent",
"name": "ruff (lint) - aries_cloudagent",
"type": "python",
"request": "launch",
"module": "ruff",
Expand All @@ -71,7 +71,7 @@
"args": ["check", "."]
},
{
"name": "ruff fix - aries_cloudagent",
"name": "ruff fix (lint) - aries_cloudagent",
"type": "python",
"request": "launch",
"module": "ruff",
Expand All @@ -82,7 +82,7 @@
"args": ["check", ".", "--fix"]
},
{
"name": "ruff - current file",
"name": "ruff (lint) - current file",
"type": "python",
"request": "launch",
"module": "ruff",
Expand All @@ -93,52 +93,37 @@
"args": ["check", ".", "${file}"]
},
{
"name": "black (check) - aries_cloudagent",
"name": "ruff fix (lint) - current file",
"type": "python",
"request": "launch",
"module": "black",
"module": "ruff",
"console": "integratedTerminal",
"sudo": true,
"justMyCode": true,
"cwd": "${workspaceFolder}/aries_cloudagent",
"args": [
".",
"--check"
]
"args": ["check", ".", "${file}", "--fix"]
},
{
"name": "black (check) - current file",
"name": "ruff (format) - aries_cloudagent",
"type": "python",
"request": "launch",
"module": "black",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"${file}",
"--check"
]
},
{
"name": "black (format) - aries_cloudagent",
"type": "python",
"request": "launch",
"module": "black",
"module": "ruff",
"console": "integratedTerminal",
"sudo": true,
"justMyCode": true,
"cwd": "${workspaceFolder}/aries_cloudagent",
"args": [
"."
]
"args": ["format", "."]
},
{
"name": "black (format) - current file",
"name": "ruff (format) - current file",
"type": "python",
"request": "launch",
"module": "black",
"module": "ruff",
"console": "integratedTerminal",
"sudo": true,
"justMyCode": true,
"args": [
"${file}"
]
"cwd": "${workspaceFolder}/aries_cloudagent",
"args": ["format", "${file}"]
}
]
}
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Contributions are made pursuant to the Developer's Certificate of Origin, availa

A configuration for [pre-commit](https://pre-commit.com/) is included in this repository. This is an optional tool to help contributors commit code that follows the formatting requirements enforced by the CI pipeline. Additionally, it can be used to help contributors write descriptive commit messages that can be parsed by changelog generators.

On each commit, pre-commit hooks will run that verify the committed code complies with ruff and is formatted with black. To install the ruff and black checks:
On each commit, pre-commit hooks will run that verify the committed code complies and formats with ruff. To install the ruff checks:

```bash
pre-commit install
Expand Down
5 changes: 3 additions & 2 deletions aries_cloudagent/admin/request_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from typing import Mapping, Optional, Type

from ..core.profile import Profile, ProfileSession
from ..config.injector import Injector, InjectionError, InjectType
from ..config.injection_context import InjectionContext
from ..config.injector import InjectionError, Injector, InjectType
from ..config.settings import Settings
from ..core.profile import Profile, ProfileSession
from ..utils.classloader import DeferLoad

IN_MEM = DeferLoad("aries_cloudagent.core.in_memory.InMemoryProfile")
Expand Down Expand Up @@ -78,6 +78,7 @@ def inject(
Args:
cls: The base class to retrieve an instance of
base_cls: The base class to retrieve an instance of
settings: An optional mapping providing configuration to the provider
Returns:
Expand Down
23 changes: 14 additions & 9 deletions aries_cloudagent/admin/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def __init__(
"""Initialize an instance of `AdminResponder`.
Args:
send: Function to send outbound message
profile (Profile): The profile for this responder.
send (Coroutine): Function to send outbound message.
**kwargs: Additional keyword arguments.
"""
super().__init__(**kwargs)
Expand All @@ -98,6 +100,7 @@ async def send_outbound(
Args:
message: The `OutboundMessage` to be sent
**kwargs: Additional keyword arguments
"""
profile = self._profile()
if not profile:
Expand Down Expand Up @@ -227,14 +230,16 @@ def __init__(
"""Initialize an AdminServer instance.
Args:
host: Host to listen on
port: Port to listen on
context: The application context instance
outbound_message_router: Coroutine for delivering outbound messages
webhook_router: Callable for delivering webhooks
conductor_stop: Conductor (graceful) stop for shutdown API call
task_queue: An optional task queue for handlers
conductor_stats: Conductor statistics API call
host (str): The host to listen on.
port (int): The port to listen on.
context (InjectionContext): The application context instance.
root_profile (Profile): The root profile.
outbound_message_router (Coroutine): Coroutine for delivering
outbound messages.
webhook_router (Callable): Callable for delivering webhooks.
conductor_stop (Coroutine): Conductor (graceful) stop for shutdown API call.
task_queue (TaskQueue, optional): An optional task queue for handlers.
conductor_stats (Coroutine, optional): Conductor statistics API call.
"""
self.app = None
self.admin_api_key = context.settings.get("admin.admin_api_key")
Expand Down
8 changes: 5 additions & 3 deletions aries_cloudagent/anoncreds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def __init__(
"""Initialize an instance.
Args:
message: Message
obj_id: Object ID
obj: Generic Object
message (str): The message associated with the instance.
obj_id (str): The ID of the object.
obj (T, optional): The generic object associated with the instance.
*args: Variable length argument list.
**kwargs: Arbitrary keyword arguments.
"""
super().__init__(message, obj_id, obj, *args, **kwargs)
self._message = message
Expand Down
6 changes: 5 additions & 1 deletion aries_cloudagent/anoncreds/default/did_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ async def register_revocation_registry_definition(
raise NotImplementedError()

async def get_revocation_list(
self, profile: Profile, revocation_registry_id: str, timestamp: int
self,
profile: Profile,
revocation_registry_id: str,
timestamp_from: Optional[int] = 0,
timestamp_to: Optional[int] = None,
) -> GetRevListResult:
"""Get a revocation list from the registry."""
raise NotImplementedError()
Expand Down
16 changes: 12 additions & 4 deletions aries_cloudagent/anoncreds/default/legacy_indy/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,14 +743,18 @@ async def _get_ledger(self, profile: Profile, rev_reg_def_id: str):
return ledger_id, ledger

async def get_revocation_registry_delta(
self, profile: Profile, rev_reg_def_id: str, timestamp: None
self,
profile: Profile,
rev_reg_def_id: str,
timestamp_from: Optional[int] = 0,
timestamp_to: Optional[int] = None,
) -> Tuple[dict, int]:
"""Fetch the revocation registry delta."""
ledger_id, ledger = await self._get_ledger(profile, rev_reg_def_id)

async with ledger:
delta, timestamp = await ledger.get_revoc_reg_delta(
rev_reg_def_id, timestamp_to=timestamp
rev_reg_def_id, timestamp_from=timestamp_from, timestamp_to=timestamp_to
)

if delta is None:
Expand All @@ -762,13 +766,17 @@ async def get_revocation_registry_delta(
return delta, timestamp

async def get_revocation_list(
self, profile: Profile, rev_reg_def_id: str, timestamp: int
self,
profile: Profile,
rev_reg_def_id: str,
timestamp_from: Optional[int] = 0,
timestamp_to: Optional[int] = None,
) -> GetRevListResult:
"""Get the revocation registry list."""
_, ledger = await self._get_ledger(profile, rev_reg_def_id)

delta, timestamp = await self.get_revocation_registry_delta(
profile, rev_reg_def_id, timestamp
profile, rev_reg_def_id, timestamp_from, timestamp_to
)

async with ledger:
Expand Down
Loading

0 comments on commit d02441e

Please sign in to comment.