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

[#186] Ruff linting and formatting within Bazel #273

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5a8b509
Renamed agent.h
eddiebrissow Feb 17, 2025
bf23cb7
Creating links
eddiebrissow Feb 18, 2025
ce63f3d
Fixing tests
eddiebrissow Feb 18, 2025
681bbf4
Fixing tests
eddiebrissow Feb 18, 2025
611bf81
feature: add python linter and formatter within bazel
pedro-costa-techlabs Feb 19, 2025
bad9ec8
feature: lint-all and format-all make instructions
pedro-costa-techlabs Feb 20, 2025
2974899
feature: ruff.toml configuration
pedro-costa-techlabs Feb 20, 2025
c62c521
fix: remove test cli build target
pedro-costa-techlabs Feb 20, 2025
750776e
fix: format and lint all python files
pedro-costa-techlabs Feb 20, 2025
4c25829
Merge pull request #271 from singnet/issue-209-inference-agent-support
eddiebrissow Feb 20, 2025
42fc3c4
fix(tests): annotate to fix later B006 problem
pedro-costa-techlabs Feb 20, 2025
b4d8b96
Added `test --notest_keep_going` to .bazelrc
angeloprobst Feb 21, 2025
b01c594
task: move --define to .bazelrc
pedro-costa-techlabs Feb 21, 2025
81daf8a
Merge pull request #277 from singnet/pedro/276/bazelrc_defines_versions
Pedrobc89 Feb 21, 2025
ec889e7
feature: add python linter and formatter within bazel
pedro-costa-techlabs Feb 19, 2025
f36f50c
feature: lint-all and format-all make instructions
pedro-costa-techlabs Feb 20, 2025
db0713e
feature: ruff.toml configuration
pedro-costa-techlabs Feb 20, 2025
c3f7fe7
fix: remove test cli build target
pedro-costa-techlabs Feb 20, 2025
5f60002
fix: format and lint all python files
pedro-costa-techlabs Feb 20, 2025
d931e89
fix(tests): annotate to fix later B006 problem
pedro-costa-techlabs Feb 20, 2025
6a6a6aa
task: improved lint-all command filtering success lines out
pedro-costa-techlabs Feb 21, 2025
9e06bde
Merge branch 'pedro/186/linting' of github.com:singnet/das into pedro…
pedro-costa-techlabs Feb 21, 2025
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
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ bazel:
@bash ./src/scripts/bazel.sh $(filter-out $@, $(MAKECMDGOALS))

test-all: build-image
$(MAKE) bazel test //...
@$(MAKE) bazel test //...

lint-all:
@$(MAKE) bazel lint \
"//... --fix --report --diff" \
| grep -vE "(Lint results|All checks passed|^[[:blank:]]*$$)"

format-all:
@$(MAKE) bazel run format

# Catch-all pattern to prevent make from complaining about unknown targets
%:
Expand Down
3 changes: 3 additions & 0 deletions src/.aspect/cli/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lint:
aspects:
- //tools/lint:linters.bzl%ruff
2 changes: 2 additions & 0 deletions src/.bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BAZELISK_BASE_URL=https://github.com/aspect-build/aspect-cli/releases/download
USE_BAZEL_VERSION=aspect/2024.49.18
7 changes: 7 additions & 0 deletions src/.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ common --enable_bzlmod
# localy
build --spawn_strategy=local

# Define versions
build --define=ATOMDB_VERSION=0.8.11
build --define=DAS_VERSION=0.9.17
build --define=DAS_NODE_VERSION=0.0.1

# Enable debugging symbols for development
build:debug --compilation_mode=dbg
build:debug --strip=never


# Optimeze for speed in production
build:release --compilation_mode=opt
build:release --strip=always
Expand All @@ -40,6 +46,7 @@ test --flaky_test_attempts=1
test --cache_test_results=auto
test --test_env=BAZEL_TEST_ENV=1
test --test_tag_filters=-skip
test --notest_keep_going

#################################### RUN ######################################

36 changes: 36 additions & 0 deletions src/.ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
line-length = 100
indent-width = 4

target-version = "py310"

[lint]

select = ["E4", "E7", "E9", "F", "B"]
ignore = ["E501", "B905"]
fixable = ["ALL"]
unfixable = ["B"]


# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"


# Ignore `E402` (import violations) in all `__init__.py` files.
[lint.per-file-ignores]
"__init__.py" = ["E402", "F403"]
"**/{tests,docs,tools}/*" = ["B006", "B011", "B017", "B018"]
# Auto generated code
"**/grpc/*.py" = ["ALL"]

[format]
quote-style = "double"

indent-style = "space"

skip-magic-trailing-comma = false

line-ending = "auto"

# Enable auto-formatting of code examples in docstrings
docstring-code-format = true
docstring-code-line-length = "dynamic"
17 changes: 17 additions & 0 deletions src/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
package(default_visibility = ["//visibility:public"])

exports_files(
[
".ruff.toml",
],
visibility = ["//visibility:public"],
)

alias(
name = "format.check",
actual = "//tools/format:format.check"
)

alias(
name = "format",
actual = "//tools/format"
)

cc_binary(
name = "attention_broker_service",
srcs = [],
Expand Down
2 changes: 2 additions & 0 deletions src/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Additionally, this file configures:

module(name = "das")

# Bazel to run linters and formatters
bazel_dep(name = "aspect_rules_lint", version = "1.2.0")

# C++

Expand Down
829 changes: 829 additions & 0 deletions src/MODULE.bazel.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/hyperon_das/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sys

if sys.version_info < (3, 10):
raise RuntimeError('hyperon_das requires Python 3.10 or higher')
raise RuntimeError("hyperon_das requires Python 3.10 or higher")

from hyperon_das.das import DistributedAtomSpace

__all__ = ['DistributedAtomSpace']
__all__ = ["DistributedAtomSpace"]

__version__ = '0.9.14'
__version__ = "0.9.14"
12 changes: 6 additions & 6 deletions src/hyperon_das/cache/attention_broker_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ def __init__(self, system_parameters: Dict[str, Any]):
f"Invalid system parameters. server_hostname: '{self.server_hostname}' server_port: {self.server_port}"
)
)
self.server_url = f'{self.server_hostname}:{self.server_port}'
self.server_url = f"{self.server_hostname}:{self.server_port}"
self.ping()

def ping(self) -> Optional[str]:
logger().info(f'Pinging AttentionBroker at {self.server_url}')
logger().info(f"Pinging AttentionBroker at {self.server_url}")
with grpc.insecure_channel(self.server_url) as channel:
stub = AttentionBrokerStub(channel)
response = stub.ping(grpc_types.Empty())
Expand All @@ -33,9 +33,9 @@ def ping(self) -> Optional[str]:

def stimulate(self, handle_count: Set[str]) -> Optional[str]:
if handle_count is None:
das_error(ValueError(f'Invalid handle_count {handle_count}'))
das_error(ValueError(f"Invalid handle_count {handle_count}"))
logger().info(
f'Requesting AttentionBroker at {self.server_url} to stimulate {len(handle_count)} atoms'
f"Requesting AttentionBroker at {self.server_url} to stimulate {len(handle_count)} atoms"
)
message = grpc_types.HandleCount(handle_count=handle_count)
with grpc.insecure_channel(self.server_url) as channel:
Expand All @@ -47,9 +47,9 @@ def stimulate(self, handle_count: Set[str]) -> Optional[str]:

def correlate(self, handle_set: Set[str]) -> Optional[str]:
if handle_set is None:
das_error(ValueError(f'Invalid handle_set {handle_set}'))
das_error(ValueError(f"Invalid handle_set {handle_set}"))
logger().info(
f'Requesting AttentionBroker at {self.server_url} to correlate {len(handle_set)} atoms'
f"Requesting AttentionBroker at {self.server_url} to correlate {len(handle_set)} atoms"
)
message = grpc_types.HandleList(handle_list=handle_set)
sleep(0.05)
Expand Down
Loading