Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
ca3acf2
Remove filters
dgarros Oct 3, 2024
935aabc
bump version to 0.15.0a0 for develop
lykinsbd Oct 4, 2024
4137416
Remove filters
dgarros Oct 3, 2024
e82e31d
Update protocols
dgarros Oct 7, 2024
ecb18f0
Merge pull request #53 from opsmill/dga-20241003-ifc-filters
dgarros Oct 8, 2024
ae241a5
Merge pull request #62 from opsmill/dga-20241007-newmenu
dgarros Oct 8, 2024
844b268
Merge branch 'stable' into stable-mergeback
ajtmccarty Oct 8, 2024
4fb041f
Merge pull request #63 from opsmill/stable-mergeback
dgarros Oct 9, 2024
e6503b8
Upload coverage reports to codecov
ogenstad Oct 11, 2024
7320e74
Merge pull request #67 from opsmill/pog-code-cov
ogenstad Oct 11, 2024
fa3475b
changes the default connection timeout to 60s
wvandeun Oct 11, 2024
43e78af
Add config file for codecov
ogenstad Oct 11, 2024
926d8ba
Merge pull request #70 from opsmill/pog-codecov-config
ogenstad Oct 11, 2024
8f7f780
Merge pull request #69 from opsmill/wvd-20241011-change-default-conne…
wvandeun Oct 11, 2024
356bfb2
Add infrahubctl menu load command to load menu items from a file
dgarros Oct 13, 2024
258b3ff
Replace pipe None with optional for Python 3.9
dgarros Oct 13, 2024
69e8600
Set codecov target for PRs and changes
ogenstad Oct 14, 2024
c46c063
Merge pull request #74 from opsmill/pog-codecov-target
ogenstad Oct 14, 2024
86833ad
Run python tests after changes to codecov.yml
ogenstad Oct 14, 2024
472d01c
Merge pull request #75 from opsmill/pog-run-python-tests-after-covera…
ogenstad Oct 14, 2024
970ed71
Fix broken SDK playback
ogenstad Oct 11, 2024
d03e036
Merge pull request #72 from opsmill/pog-fix-playback
ogenstad Oct 14, 2024
cd83cde
Improve support for relationship & cleanup
dgarros Oct 14, 2024
8222579
Merge pull request #73 from opsmill/dga-20241012-menu
dgarros Oct 14, 2024
f67f360
Support code to be integrated into infrahub-server
dgarros Oct 14, 2024
33ce8ab
Merge pull request #78 from opsmill/dga-20241014-pr4625
dgarros Oct 14, 2024
7e7abd2
Convert import paths to use relative name
dgarros Oct 15, 2024
7a76cb4
Run coverage separately
ogenstad Oct 15, 2024
fb49d7e
Use relative path in the pytest plugin
dgarros Oct 15, 2024
2bb8bec
Merge pull request #79 from opsmill/pog-coverage
ogenstad Oct 15, 2024
7e4f1cd
Limit coverage run to --source=infrahub_sdk
ogenstad Oct 15, 2024
8cb60be
Cleanup ignored type annotations
ogenstad Oct 15, 2024
0bf8d1d
Fix Ruff B007 fix Loop control variable not used within loop body
ogenstad Oct 15, 2024
7af15d3
Fix Yoda condition (SIM300)
ogenstad Oct 15, 2024
da7cd5d
Activate rule for B018 for useless attribute access
ogenstad Oct 15, 2024
b4ea045
Merge pull request #87 from opsmill/pog-activate-b018
ogenstad Oct 16, 2024
64d0271
Merge pull request #85 from opsmill/pog-b007
ogenstad Oct 16, 2024
b91acac
Merge pull request #86 from opsmill/pog-yoda
ogenstad Oct 16, 2024
3a945c8
Merge pull request #83 from opsmill/pog-limit-coverage-to-sdk
ogenstad Oct 16, 2024
b889934
Merge pull request #84 from opsmill/pog-cleanup-typing-ignores
ogenstad Oct 16, 2024
13bd900
Merge stable into develop and fix merge conflict
ogenstad Oct 17, 2024
37adb41
Remove 'await' in front of initialize_client()
ogenstad Oct 17, 2024
43879f6
Merge pull request #88 from opsmill/pog-merge-back-stable
ogenstad Oct 17, 2024
d2599ec
Fix typehints and remove type ignores for ctl.importer & exporter
ogenstad Oct 17, 2024
7040f72
Merge pull request #80 from opsmill/dga-20241015
dgarros Oct 17, 2024
e980a9a
Fix typing on ctl.utils
ogenstad Oct 17, 2024
49d4834
Remove exports from `infrahub_sdk.__init__.py`
ogenstad Oct 17, 2024
f493f0e
Fix linting issues
ogenstad Oct 17, 2024
fad05dc
Merge pull request #91 from opsmill/pog-ctl-importer
ogenstad Oct 17, 2024
e4b8cd5
Merge pull request #92 from opsmill/pog-typing-utils
ogenstad Oct 17, 2024
3224641
Merge pull request #95 from opsmill/pog-linting-issues
ogenstad Oct 17, 2024
1ac18f6
Fix typing for CLI commands
ogenstad Oct 17, 2024
e6cffd7
Merge pull request #94 from opsmill/pog-cli-commands-typing
ogenstad Oct 17, 2024
e797e10
Add support for specific timout per request per issue #25
Oct 17, 2024
337ad72
Merge branch 'develop' into ps-add-timeouts
Oct 17, 2024
ada9ac4
Add timeout param to InfrahubClient create method.
Oct 17, 2024
ed48858
Merge pull request #93 from opsmill/pog-remove-exports
ogenstad Oct 18, 2024
21be6c4
Fix deprecation warning
ogenstad Oct 18, 2024
23ca672
Merge pull request #97 from opsmill/pog-fix-deprecation-warning
ogenstad Oct 18, 2024
2c95e81
Merging stable to develop
lykinsbd Oct 22, 2024
9ba9864
Merge pull request #101 from opsmill/bdl-20241022-mergeback
lykinsbd Oct 22, 2024
168d715
Ignore specific RUF rules instead of ignoring everything
ogenstad Oct 22, 2024
d0ad16e
Merge pull request #103 from opsmill/pog-ruff-ignore-rules
ogenstad Oct 23, 2024
be17bc3
Merge pull request #96 from PhillSimonds/ps-add-timeouts
ogenstad Oct 23, 2024
c12afcc
Correct autofixable ruff violations
ogenstad Oct 23, 2024
39fdcf0
Merge pull request #106 from opsmill/pog-ruf-ruleset
ogenstad Oct 24, 2024
544b42c
Update protocols to match latest core schema
dgarros Oct 24, 2024
92b9567
Merge pull request #107 from opsmill/dga-20241024-menu
dgarros Oct 25, 2024
45925ed
Upgrade ruff to 0.7.1
ogenstad Oct 26, 2024
5bbb22d
Merge pull request #108 from opsmill/pog-upgrade-ruff
ogenstad Oct 26, 2024
065729b
Add ability to initialize a Check with a client
ogenstad Oct 30, 2024
bcedf52
Return friendly errors on file encoding violations
ogenstad Oct 30, 2024
2e04802
Merge pull request #115 from opsmill/pog-add-client-to-check
ogenstad Oct 30, 2024
b008784
Merge pull request #114 from opsmill/pog-friendly-error-on-encoding-e…
ogenstad Oct 30, 2024
85cdb7b
bump to version 1.0.0
wvandeun Oct 31, 2024
7a47662
adding missing changelog entry
wvandeun Oct 31, 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
5 changes: 5 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ ci_config: &ci_config
- ".github/workflows/ci.yml"
- ".github/file-filters.yml"

coverage_config: &coverage_config
- "codecov.yml"

github_workflows: &github_workflows
- ".github/workflows/*.yml"

Expand All @@ -20,6 +23,8 @@ doc_files: &doc_files
python_all: &python_all
- "**/*.py"
- *poetry_files
- *ci_config
- *coverage_config

yaml_all: &yaml_all
- "**/*.{yml,yaml}"
Expand Down
25 changes: 22 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: "Check out repository code"
uses: "actions/checkout@v4"
- name: "Setup environment"
run: "pip install ruff==0.5.0"
run: "pip install ruff==0.7.1"
- name: "Linting: ruff check"
run: "ruff check ."
- name: "Linting: ruff format"
Expand Down Expand Up @@ -142,12 +142,31 @@ jobs:
run: |
pipx install poetry
poetry config virtualenvs.prefer-active-python true
pip install invoke toml
pip install invoke toml codecov
- name: "Install Package"
run: "poetry install --all-extras"
- name: "Mypy Tests"
run: "poetry run mypy --show-error-codes infrahub_sdk/"
# - name: "Pylint Tests"
# run: "poetry run pylint infrahub_sdk/"
- name: "Unit Tests"
run: "poetry run pytest tests/unit/"
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
- name: "Upload coverage to Codecov"
run: |
codecov --flags python-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# The pytest-cov plugin doesn't quite work with content that is
# auto-imported by our own infrahub pytest plugin, this workaround
# reports the missing lines
- name: "Report coverage for pytest-plugin"
if: matrix.python-version == '3.12'
run: |
source $(poetry env info --path)/bin/activate
coverage run --source=infrahub_sdk -m pytest tests/unit/pytest_plugin
coverage report -m
coverage xml
codecov --flags python-filler-${{ matrix.python-version }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ extends: default
ignore: |
/.venv
/examples
tests/unit/sdk/test_data/schema_encoding_error.yml

rules:
new-lines: disable
Expand Down
1 change: 1 addition & 0 deletions changelog/+8dff6891.removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Breaking change: Removed all exports from infrahub_sdk/__init__.py except InfrahubClient, InfrahubClientSync and Config. If you previously imported other classes such as InfrahubNode from the root level these need to change to instead be an absolute path.
1 change: 1 addition & 0 deletions changelog/+connection-timeout.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed the default connection timeout in the SDK to 60s.
1 change: 1 addition & 0 deletions changelog/+infrahubctl-menu.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added `infrahubctl menu` command to load menu definitions into Infrahub
1 change: 1 addition & 0 deletions changelog/+urlencode-url-parameters.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes an issue where InfrahubClient was not properly URL encoding URL parameters.
1 change: 1 addition & 0 deletions changelog/102.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CTL: Return friendly error on encoding violations when reading files.
1 change: 1 addition & 0 deletions changelog/25.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for specific timeout per request on InfrahubClient and InfrahubNode function calls.
1 change: 1 addition & 0 deletions changelog/64.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix SDK playback hash generation to read the correct filename
17 changes: 17 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
coverage:
status:
project:
default:
target: 0%
# Set the threshold to allow a decrease of up to 5% without failing the PR
threshold: 5%
patch:
default:
target: 0%
# Set the threshold to allow a decrease of up to 5% in patch coverage without failing the PR
threshold: 5%

comment:
layout: "header, diff, flags, files"
behavior: default
72 changes: 6 additions & 66 deletions infrahub_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,16 @@

import importlib.metadata

from infrahub_sdk.analyzer import GraphQLOperation, GraphQLQueryAnalyzer, GraphQLQueryVariable
from infrahub_sdk.batch import InfrahubBatch
from infrahub_sdk.branch import InfrahubBranchManager, InfrahubBranchManagerSync
from infrahub_sdk.client import InfrahubClient, InfrahubClientSync
from infrahub_sdk.config import Config
from infrahub_sdk.exceptions import (
AuthenticationError,
Error,
GraphQLError,
NodeNotFoundError,
ServerNotReachableError,
ServerNotResponsiveError,
ValidationError,
)
from infrahub_sdk.graphql import Mutation, Query
from infrahub_sdk.node import InfrahubNode, InfrahubNodeSync
from infrahub_sdk.schema import (
AttributeSchema,
GenericSchema,
InfrahubRepositoryConfig,
InfrahubSchema,
MainSchemaTypes,
NodeSchema,
ProfileSchema,
RelationshipCardinality,
RelationshipKind,
RelationshipSchema,
SchemaRoot,
)
from infrahub_sdk.store import NodeStore, NodeStoreSync
from infrahub_sdk.timestamp import Timestamp
from infrahub_sdk.uuidt import UUIDT, generate_uuid
from .client import InfrahubClient, InfrahubClientSync
from .config import Config

__all__ = [
"AttributeSchema",
"AuthenticationError",
"Config",
"Error",
"InfrahubBatch",
"InfrahubBranchManager",
"InfrahubBranchManagerSync",
"InfrahubClient",
"InfrahubClientSync",
"InfrahubNode",
"InfrahubNodeSync",
"InfrahubRepositoryConfig",
"InfrahubSchema",
"generate_uuid",
"GenericSchema",
"GraphQLQueryAnalyzer",
"GraphQLQueryVariable",
"GraphQLError",
"GraphQLOperation",
"MainSchemaTypes",
"NodeNotFoundError",
"NodeSchema",
"Mutation",
"NodeStore",
"NodeStoreSync",
"ProfileSchema",
"Query",
"RelationshipSchema",
"RelationshipCardinality",
"RelationshipKind",
"SchemaRoot",
"ServerNotReachableError",
"ServerNotResponsiveError",
"Timestamp",
"UUIDT",
"ValidationError",
]

__version__ = importlib.metadata.version("infrahub-sdk")
try:
__version__ = importlib.metadata.version("infrahub-sdk")
except importlib.metadata.PackageNotFoundError:
__version__ = importlib.metadata.version("infrahub-server")

Check warning on line 17 in infrahub_sdk/__init__.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/__init__.py#L16-L17

Added lines #L16 - L17 were not covered by tests
4 changes: 2 additions & 2 deletions infrahub_sdk/_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import sys
from typing import TYPE_CHECKING, Optional

from infrahub_sdk.exceptions import ModuleImportError
from .exceptions import ModuleImportError

if TYPE_CHECKING:
from pathlib import Path
Expand All @@ -27,7 +27,7 @@
try:
module = importlib.import_module(module_name)
except ModuleNotFoundError as exc:
raise ModuleImportError(message=f"{str(exc)} ({module_path})") from exc
raise ModuleImportError(message=f"{exc!s} ({module_path})") from exc

Check warning on line 30 in infrahub_sdk/_importer.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/_importer.py#L30

Added line #L30 was not covered by tests
except SyntaxError as exc:
raise ModuleImportError(message=str(exc)) from exc

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
)
from pydantic import BaseModel

from infrahub_sdk.utils import calculate_dict_depth, calculate_dict_height, extract_fields
from .utils import calculate_dict_depth, calculate_dict_height, extract_fields


class GraphQLQueryVariable(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from dataclasses import dataclass
from typing import Any, AsyncGenerator, Awaitable, Callable, Optional

from infrahub_sdk.node import InfrahubNode
from .node import InfrahubNode


@dataclass
Expand Down
8 changes: 4 additions & 4 deletions infrahub_sdk/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

from pydantic import BaseModel

from infrahub_sdk.exceptions import BranchNotFoundError
from infrahub_sdk.graphql import Mutation, Query
from infrahub_sdk.utils import decode_json
from .exceptions import BranchNotFoundError
from .graphql import Mutation, Query
from .utils import decode_json

if TYPE_CHECKING:
from infrahub_sdk.client import InfrahubClient, InfrahubClientSync
from .client import InfrahubClient, InfrahubClientSync


class BranchData(BaseModel):
Expand Down
20 changes: 16 additions & 4 deletions infrahub_sdk/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from git.repo import Repo
from pydantic import BaseModel, Field

from infrahub_sdk import InfrahubClient
from infrahub_sdk.exceptions import InfrahubCheckNotFoundError
from . import InfrahubClient
from .exceptions import InfrahubCheckNotFoundError, UninitializedError

if TYPE_CHECKING:
from pathlib import Path

from infrahub_sdk.schema import InfrahubCheckDefinitionConfig
from .schema import InfrahubCheckDefinitionConfig

INFRAHUB_CHECK_VARIABLE_TO_IMPORT = "INFRAHUB_CHECKS"

Expand All @@ -41,6 +41,7 @@
output: Optional[str] = None,
initializer: Optional[InfrahubCheckInitializer] = None,
params: Optional[dict] = None,
client: Optional[InfrahubClient] = None,
):
self.git: Optional[Repo] = None
self.initializer = initializer or InfrahubCheckInitializer()
Expand All @@ -55,7 +56,7 @@

self.root_directory = root_directory or os.getcwd()

self.client: InfrahubClient
self._client = client

if not self.name:
self.name = self.__class__.__name__
Expand All @@ -66,6 +67,17 @@
def __str__(self) -> str:
return self.__class__.__name__

@property
def client(self) -> InfrahubClient:
if self._client:
return self._client

raise UninitializedError(message="This check has not been initialized with a client")

Check warning on line 75 in infrahub_sdk/checks.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/checks.py#L75

Added line #L75 was not covered by tests

@client.setter
def client(self, value: InfrahubClient) -> None:
self._client = value

@classmethod
async def init(cls, client: Optional[InfrahubClient] = None, *args: Any, **kwargs: Any) -> InfrahubCheck:
"""Async init method, If an existing InfrahubClient client hasn't been provided, one will be created automatically."""
Expand Down
Loading