Skip to content

Convert import paths to use relative Package name #80

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

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 12 additions & 12 deletions infrahub_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

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 (
from .analyzer import GraphQLOperation, GraphQLQueryAnalyzer, GraphQLQueryVariable
from .batch import InfrahubBatch
from .branch import InfrahubBranchManager, InfrahubBranchManagerSync
from .client import InfrahubClient, InfrahubClientSync
from .config import Config
from .exceptions import (

Check warning on line 10 in infrahub_sdk/__init__.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/__init__.py#L5-L10

Added lines #L5 - L10 were not covered by tests
AuthenticationError,
Error,
GraphQLError,
Expand All @@ -16,9 +16,9 @@
ServerNotResponsiveError,
ValidationError,
)
from infrahub_sdk.graphql import Mutation, Query
from infrahub_sdk.node import InfrahubNode, InfrahubNodeSync
from infrahub_sdk.schema import (
from .graphql import Mutation, Query
from .node import InfrahubNode, InfrahubNodeSync
from .schema import (

Check warning on line 21 in infrahub_sdk/__init__.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/__init__.py#L19-L21

Added lines #L19 - L21 were not covered by tests
AttributeSchema,
GenericSchema,
InfrahubRepositoryConfig,
Expand All @@ -31,9 +31,9 @@
RelationshipSchema,
SchemaRoot,
)
from infrahub_sdk.store import NodeStore, NodeStoreSync
from infrahub_sdk.timestamp import Timestamp
from infrahub_sdk.uuidt import UUIDT, generate_uuid
from .store import NodeStore, NodeStoreSync
from .timestamp import Timestamp
from .uuidt import UUIDT, generate_uuid

Check warning on line 36 in infrahub_sdk/__init__.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/__init__.py#L34-L36

Added lines #L34 - L36 were not covered by tests

__all__ = [
"AttributeSchema",
Expand Down
2 changes: 1 addition & 1 deletion 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

Check warning on line 7 in infrahub_sdk/_importer.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/_importer.py#L7

Added line #L7 was not covered by tests

if TYPE_CHECKING:
from pathlib import Path
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

Check warning on line 15 in infrahub_sdk/analyzer.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/analyzer.py#L15

Added line #L15 was not covered by tests


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

Check warning on line 5 in infrahub_sdk/batch.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/batch.py#L5

Added line #L5 was not covered by tests


@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

Check warning on line 9 in infrahub_sdk/branch.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/branch.py#L7-L9

Added lines #L7 - L9 were not covered by tests

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


class BranchData(BaseModel):
Expand Down
6 changes: 3 additions & 3 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

Check warning on line 14 in infrahub_sdk/checks.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/checks.py#L13-L14

Added lines #L13 - L14 were not covered by tests

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 Down
36 changes: 18 additions & 18 deletions infrahub_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,38 +23,38 @@
import ujson
from typing_extensions import Self

from infrahub_sdk.batch import InfrahubBatch
from infrahub_sdk.branch import (
from .batch import InfrahubBatch
from .branch import (

Check warning on line 27 in infrahub_sdk/client.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/client.py#L26-L27

Added lines #L26 - L27 were not covered by tests
BranchData,
InfrahubBranchManager,
InfrahubBranchManagerSync,
)
from infrahub_sdk.config import Config
from infrahub_sdk.constants import InfrahubClientMode
from infrahub_sdk.data import RepositoryBranchInfo, RepositoryData
from infrahub_sdk.diff import NodeDiff, diff_tree_node_to_node_diff, get_diff_summary_query
from infrahub_sdk.exceptions import (
from .config import Config
from .constants import InfrahubClientMode
from .data import RepositoryBranchInfo, RepositoryData
from .diff import NodeDiff, diff_tree_node_to_node_diff, get_diff_summary_query
from .exceptions import (

Check warning on line 36 in infrahub_sdk/client.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/client.py#L32-L36

Added lines #L32 - L36 were not covered by tests
AuthenticationError,
Error,
GraphQLError,
NodeNotFoundError,
ServerNotReachableError,
ServerNotResponsiveError,
)
from infrahub_sdk.graphql import Mutation, Query
from infrahub_sdk.node import (
from .graphql import Mutation, Query
from .node import (

Check warning on line 45 in infrahub_sdk/client.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/client.py#L44-L45

Added lines #L44 - L45 were not covered by tests
InfrahubNode,
InfrahubNodeSync,
)
from infrahub_sdk.object_store import ObjectStore, ObjectStoreSync
from infrahub_sdk.protocols_base import CoreNode, CoreNodeSync
from infrahub_sdk.queries import get_commit_update_mutation
from infrahub_sdk.query_groups import InfrahubGroupContext, InfrahubGroupContextSync
from infrahub_sdk.schema import InfrahubSchema, InfrahubSchemaSync, NodeSchema
from infrahub_sdk.store import NodeStore, NodeStoreSync
from infrahub_sdk.timestamp import Timestamp
from infrahub_sdk.types import AsyncRequester, HTTPMethod, SyncRequester
from infrahub_sdk.utils import decode_json, is_valid_uuid
from .object_store import ObjectStore, ObjectStoreSync
from .protocols_base import CoreNode, CoreNodeSync
from .queries import get_commit_update_mutation
from .query_groups import InfrahubGroupContext, InfrahubGroupContextSync
from .schema import InfrahubSchema, InfrahubSchemaSync, NodeSchema
from .store import NodeStore, NodeStoreSync
from .timestamp import Timestamp
from .types import AsyncRequester, HTTPMethod, SyncRequester
from .utils import decode_json, is_valid_uuid

Check warning on line 57 in infrahub_sdk/client.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/client.py#L49-L57

Added lines #L49 - L57 were not covered by tests

if TYPE_CHECKING:
from types import TracebackType
Expand Down
6 changes: 3 additions & 3 deletions infrahub_sdk/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import jinja2

from infrahub_sdk import protocols as sdk_protocols
from infrahub_sdk.ctl.constants import PROTOCOLS_TEMPLATE
from infrahub_sdk.schema import (
from . import protocols as sdk_protocols
from .ctl.constants import PROTOCOLS_TEMPLATE
from .schema import (
AttributeSchema,
GenericSchema,
MainSchemaTypes,
Expand Down
10 changes: 5 additions & 5 deletions infrahub_sdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from pydantic_settings import BaseSettings, SettingsConfigDict
from typing_extensions import Self

from infrahub_sdk.constants import InfrahubClientMode
from infrahub_sdk.playback import JSONPlayback
from infrahub_sdk.recorder import JSONRecorder, NoRecorder, Recorder, RecorderType
from infrahub_sdk.types import AsyncRequester, InfrahubLoggers, RequesterTransport, SyncRequester
from infrahub_sdk.utils import get_branch, is_valid_url
from .constants import InfrahubClientMode
from .playback import JSONPlayback
from .recorder import JSONRecorder, NoRecorder, Recorder, RecorderType
from .types import AsyncRequester, InfrahubLoggers, RequesterTransport, SyncRequester
from .utils import get_branch, is_valid_url

Check warning on line 11 in infrahub_sdk/config.py

View check run for this annotation

Codecov / codecov/patch

infrahub_sdk/config.py#L7-L11

Added lines #L7 - L11 were not covered by tests


class ProxyMountsConfig(BaseSettings):
Expand Down
7 changes: 3 additions & 4 deletions infrahub_sdk/ctl/branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from rich.console import Console
from rich.table import Table

from infrahub_sdk.async_typer import AsyncTyper
from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.ctl.utils import calculate_time_diff, catch_exception

from ..async_typer import AsyncTyper
from ..ctl.client import initialize_client
from ..ctl.utils import calculate_time_diff, catch_exception
from .parameters import CONFIG_PARAM

app = AsyncTyper()
Expand Down
16 changes: 8 additions & 8 deletions infrahub_sdk/ctl/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from rich.console import Console
from rich.logging import RichHandler

from infrahub_sdk import InfrahubClient
from infrahub_sdk.checks import InfrahubCheck
from infrahub_sdk.ctl import config
from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.ctl.exceptions import QueryNotFoundError
from infrahub_sdk.ctl.repository import get_repository_config
from infrahub_sdk.ctl.utils import catch_exception, execute_graphql_query
from infrahub_sdk.schema import InfrahubCheckDefinitionConfig, InfrahubRepositoryConfig
from .. import InfrahubClient
from ..checks import InfrahubCheck
from ..ctl import config
from ..ctl.client import initialize_client
from ..ctl.exceptions import QueryNotFoundError
from ..ctl.repository import get_repository_config
from ..ctl.utils import catch_exception, execute_graphql_query
from ..schema import InfrahubCheckDefinitionConfig, InfrahubRepositoryConfig

app = typer.Typer()
console = Console()
Expand Down
49 changes: 24 additions & 25 deletions infrahub_sdk/ctl/cli_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,39 @@
from rich.logging import RichHandler
from rich.traceback import Traceback

from infrahub_sdk import __version__ as sdk_version
from infrahub_sdk.async_typer import AsyncTyper
from infrahub_sdk.code_generator import CodeGenerator
from infrahub_sdk.ctl import config
from infrahub_sdk.ctl.branch import app as branch_app
from infrahub_sdk.ctl.check import run as run_check
from infrahub_sdk.ctl.client import initialize_client, initialize_client_sync
from infrahub_sdk.ctl.exceptions import QueryNotFoundError
from infrahub_sdk.ctl.generator import run as run_generator
from infrahub_sdk.ctl.menu import app as menu_app
from infrahub_sdk.ctl.object import app as object_app
from infrahub_sdk.ctl.render import list_jinja2_transforms
from infrahub_sdk.ctl.repository import app as repository_app
from infrahub_sdk.ctl.repository import get_repository_config
from infrahub_sdk.ctl.schema import app as schema_app
from infrahub_sdk.ctl.transform import list_transforms
from infrahub_sdk.ctl.utils import (
from .. import __version__ as sdk_version
from ..async_typer import AsyncTyper
from ..code_generator import CodeGenerator
from ..ctl import config
from ..ctl.branch import app as branch_app
from ..ctl.check import run as run_check
from ..ctl.client import initialize_client, initialize_client_sync
from ..ctl.exceptions import QueryNotFoundError
from ..ctl.generator import run as run_generator
from ..ctl.menu import app as menu_app
from ..ctl.object import app as object_app
from ..ctl.render import list_jinja2_transforms
from ..ctl.repository import app as repository_app
from ..ctl.repository import get_repository_config
from ..ctl.schema import app as schema_app
from ..ctl.transform import list_transforms
from ..ctl.utils import (
catch_exception,
execute_graphql_query,
load_yamlfile_from_disk_and_exit,
parse_cli_vars,
)
from infrahub_sdk.ctl.validate import app as validate_app
from infrahub_sdk.exceptions import GraphQLError, InfrahubTransformNotFoundError
from infrahub_sdk.jinja2 import identify_faulty_jinja_code
from infrahub_sdk.schema import (
from ..ctl.validate import app as validate_app
from ..exceptions import GraphQLError, InfrahubTransformNotFoundError
from ..jinja2 import identify_faulty_jinja_code
from ..schema import (
InfrahubRepositoryConfig,
MainSchemaTypes,
SchemaRoot,
)
from infrahub_sdk.transforms import get_transform_class_instance
from infrahub_sdk.utils import get_branch, write_to_file
from infrahub_sdk.yaml import SchemaFile

from ..transforms import get_transform_class_instance
from ..utils import get_branch, write_to_file
from ..yaml import SchemaFile
from .exporter import dump
from .importer import load
from .parameters import CONFIG_PARAM
Expand Down
6 changes: 3 additions & 3 deletions infrahub_sdk/ctl/client.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from typing import Any, Optional

from infrahub_sdk import InfrahubClient, InfrahubClientSync
from infrahub_sdk.config import Config
from infrahub_sdk.ctl import config
from .. import InfrahubClient, InfrahubClientSync
from ..config import Config
from ..ctl import config


async def initialize_client(
Expand Down
7 changes: 3 additions & 4 deletions infrahub_sdk/ctl/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
import typer
from rich.console import Console

from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.transfer.exceptions import TransferError
from infrahub_sdk.transfer.exporter.json import LineDelimitedJSONExporter

from ..ctl.client import initialize_client
from ..transfer.exceptions import TransferError
from ..transfer.exporter.json import LineDelimitedJSONExporter
from .parameters import CONFIG_PARAM


Expand Down
12 changes: 6 additions & 6 deletions infrahub_sdk/ctl/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

from rich.console import Console

from infrahub_sdk import InfrahubNode
from infrahub_sdk.ctl import config
from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.ctl.repository import get_repository_config
from infrahub_sdk.ctl.utils import execute_graphql_query, parse_cli_vars
from infrahub_sdk.schema import InfrahubRepositoryConfig
from .. import InfrahubNode
from ..ctl import config
from ..ctl.client import initialize_client
from ..ctl.repository import get_repository_config
from ..ctl.utils import execute_graphql_query, parse_cli_vars
from ..schema import InfrahubRepositoryConfig


async def run(
Expand Down
9 changes: 4 additions & 5 deletions infrahub_sdk/ctl/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import typer
from rich.console import Console

from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.transfer.exceptions import TransferError
from infrahub_sdk.transfer.importer.json import LineDelimitedJSONImporter
from infrahub_sdk.transfer.schema_sorter import InfrahubSchemaTopologicalSorter

from ..ctl.client import initialize_client
from ..transfer.exceptions import TransferError
from ..transfer.importer.json import LineDelimitedJSONImporter
from ..transfer.schema_sorter import InfrahubSchemaTopologicalSorter
from .parameters import CONFIG_PARAM


Expand Down
9 changes: 4 additions & 5 deletions infrahub_sdk/ctl/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import typer
from rich.console import Console

from infrahub_sdk.async_typer import AsyncTyper
from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.ctl.utils import catch_exception, init_logging
from infrahub_sdk.spec.menu import MenuFile

from ..async_typer import AsyncTyper
from ..ctl.client import initialize_client
from ..ctl.utils import catch_exception, init_logging
from ..spec.menu import MenuFile
from .parameters import CONFIG_PARAM
from .utils import load_yamlfile_from_disk_and_exit

Expand Down
9 changes: 4 additions & 5 deletions infrahub_sdk/ctl/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
import typer
from rich.console import Console

from infrahub_sdk.async_typer import AsyncTyper
from infrahub_sdk.ctl.client import initialize_client
from infrahub_sdk.ctl.utils import catch_exception, init_logging
from infrahub_sdk.spec.object import ObjectFile

from ..async_typer import AsyncTyper
from ..ctl.client import initialize_client
from ..ctl.utils import catch_exception, init_logging
from ..spec.object import ObjectFile
from .parameters import CONFIG_PARAM
from .utils import load_yamlfile_from_disk_and_exit

Expand Down
2 changes: 1 addition & 1 deletion infrahub_sdk/ctl/parameters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import typer

from infrahub_sdk.ctl import config
from ..ctl import config


def load_configuration(value: str) -> str:
Expand Down
Loading