Skip to content

Commit

Permalink
getting there
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed Oct 4, 2024
1 parent 389cdfa commit 5d9f078
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 107 deletions.
1 change: 1 addition & 0 deletions diracx-cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@ asyncio_mode = "auto"
markers = [
"enabled_dependencies: List of dependencies which should be available to the FastAPI test client",
]
asyncio_default_fixture_loop_scope = "session"
30 changes: 3 additions & 27 deletions diracx-client/src/diracx/client/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,10 @@
class DiracxLoader(SourceFileLoader):

def create_module(self, spec):
print(f"CHRIS I LOAD !!!! {spec=}", flush=True)
if spec.name in sys.modules:
print("CHRIS ALREAY DEFINED")
return sys.modules[spec.name]

Check warning on line 16 in diracx-client/src/diracx/client/extensions.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/extensions.py#L15-L16

Added lines #L15 - L16 were not covered by tests
# breakpoint()
print(f"CHRIS HAVE TO CALL SUPER", flush=True)
# return super().create_module(spec)
# try to read txt file content
try:
with open(self.filepath) as inp_file:
self.data = inp_file.read()
except:
# raise ImportError if there was an error loading the file
raise ImportError
# when returning None, default module creation will be called

def exec_module(self, module):
print("CHRIS EXEC ", flush=True)
# breakpoint()

# here we update module and add our custom members
# module.__dict__.update({"data": self.data})

def exec_module(self, module): ...


class DiracxPathFinder(MetaPathFinder):
Expand All @@ -59,18 +41,12 @@ def find_spec(cls, fullname, path, target=None):
]
]
):
if "client.generated.models._patch" in fullname:

print(f"CHRIS find_spec {fullname=} {path=}")
for lower_extension in cls.diracx_extensions[i:][::-1]:
try:
patched_name = fullname.replace(extension, lower_extension)

Check warning on line 46 in diracx-client/src/diracx/client/extensions.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/extensions.py#L45-L46

Added lines #L45 - L46 were not covered by tests
# breakpoint()
overwritten = importlib.util.find_spec(patched_name)

Check warning on line 48 in diracx-client/src/diracx/client/extensions.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/extensions.py#L48

Added line #L48 was not covered by tests
print(
f"CHRIS patching {fullname=} {patched_name=} {overwritten}",
flush=True,
)

spec = ModuleSpec(

Check warning on line 50 in diracx-client/src/diracx/client/extensions.py

View check run for this annotation

Codecov / codecov/patch

diracx-client/src/diracx/client/extensions.py#L50

Added line #L50 was not covered by tests
patched_name, DiracxLoader(patched_name, path)
)
Expand Down
1 change: 1 addition & 0 deletions diracx-db/src/diracx/db/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async def init_sql():
from diracx.db.sql.utils import BaseSQLDB

for db_name, db_url in BaseSQLDB.available_urls().items():

logger.info("Initialising %s", db_name)
db = BaseSQLDB.available_implementations(db_name)[0](db_url)
async with db.engine_context():
Expand Down
4 changes: 3 additions & 1 deletion diracx-routers/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ addopts = [
"--import-mode=importlib",
]
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
markers = [
"enabled_dependencies: List of dependencies which should be available to the FastAPI test client",
]


asyncio_default_fixture_loop_scope = "function"
10 changes: 8 additions & 2 deletions extensions/gubbins/gubbins-cli/tests/test_gubbins_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@
runner = CliRunner()


async def test_lollygag_hello():
def test_lollygag_cli():
result = runner.invoke(app, ["--help"], env=os.environ)
assert result.exit_code == 0, result.output
assert "lollygag" in result.output, result.output


async def test_lollygag_owner(with_cli_login):
def test_lollygag_hello(with_cli_login):
result = runner.invoke(app, ["lollygag", "hello"], env=os.environ)
assert result.exit_code == 0, result.output
assert "Baby" in result.output, result.output


def test_lollygag_owner(with_cli_login):
result = runner.invoke(app, ["lollygag", "get-owners"], env=os.environ)
assert result.exit_code == 0, result.output
assert "[]" in result.output, result.output
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from io import IOBase
Expand Down Expand Up @@ -152,13 +152,13 @@ async def openid_configuration(self, **kwargs: Any) -> Any:
return deserialized # type: ignore

@distributed_trace_async
async def installation_metadata(self, **kwargs: Any) -> _models.Metadata:
async def installation_metadata(self, **kwargs: Any) -> _models.ExtendedMetadata:
"""Installation Metadata.
Installation Metadata.
:return: Metadata
:rtype: ~generated.models.Metadata
:return: ExtendedMetadata
:rtype: ~generated.models.ExtendedMetadata
:raises ~azure.core.exceptions.HttpResponseError:
"""
error_map: MutableMapping = {
Expand All @@ -172,7 +172,7 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata:
_headers = kwargs.pop("headers", {}) or {}
_params = kwargs.pop("params", {}) or {}

cls: ClsType[_models.Metadata] = kwargs.pop("cls", None)
cls: ClsType[_models.ExtendedMetadata] = kwargs.pop("cls", None)

_request = build_well_known_installation_metadata_request(
headers=_headers,
Expand All @@ -195,7 +195,9 @@ async def installation_metadata(self, **kwargs: Any) -> _models.Metadata:
)
raise HttpResponseError(response=response)

deserialized = self._deserialize("Metadata", pipeline_response.http_response)
deserialized = self._deserialize(
"ExtendedMetadata", pipeline_response.http_response
)

if cls:
return cls(pipeline_response, deserialized, {}) # type: ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._models import BodyAuthToken
from ._models import BodyAuthTokenGrantType
from ._models import DevelopmentSettings
from ._models import ExtendedMetadata
from ._models import GroupInfo
from ._models import HTTPValidationError
from ._models import InitiateDeviceFlowResponse
Expand All @@ -18,7 +19,6 @@
from ._models import JobSummaryParams
from ._models import JobSummaryParamsSearchItem
from ._models import LimitedJobStatusReturn
from ._models import Metadata
from ._models import SandboxDownloadResponse
from ._models import SandboxInfo
from ._models import SandboxUploadResponse
Expand Down Expand Up @@ -55,6 +55,7 @@
"BodyAuthToken",
"BodyAuthTokenGrantType",
"DevelopmentSettings",
"ExtendedMetadata",
"GroupInfo",
"HTTPValidationError",
"InitiateDeviceFlowResponse",
Expand All @@ -66,7 +67,6 @@
"JobSummaryParams",
"JobSummaryParamsSearchItem",
"LimitedJobStatusReturn",
"Metadata",
"SandboxDownloadResponse",
"SandboxInfo",
"SandboxUploadResponse",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=too-many-lines
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down Expand Up @@ -126,6 +126,58 @@ def __init__(
self.crash_on_missed_access_policy = crash_on_missed_access_policy


class ExtendedMetadata(_serialization.Model):
"""ExtendedMetadata.
All required parameters must be populated in order to send to server.
:ivar virtual_organizations: Virtual Organizations. Required.
:vartype virtual_organizations: dict[str, ~generated.models.VOInfo]
:ivar development_settings: Settings for the Development Configuration that can influence run
time. Required.
:vartype development_settings: ~generated.models.DevelopmentSettings
:ivar gubbins_secrets: Gubbins Secrets. Required.
:vartype gubbins_secrets: str
"""

_validation = {
"virtual_organizations": {"required": True},
"development_settings": {"required": True},
"gubbins_secrets": {"required": True},
}

_attribute_map = {
"virtual_organizations": {"key": "virtual_organizations", "type": "{VOInfo}"},
"development_settings": {
"key": "development_settings",
"type": "DevelopmentSettings",
},
"gubbins_secrets": {"key": "gubbins_secrets", "type": "str"},
}

def __init__(
self,
*,
virtual_organizations: Dict[str, "_models.VOInfo"],
development_settings: "_models.DevelopmentSettings",
gubbins_secrets: str,
**kwargs: Any,
) -> None:
"""
:keyword virtual_organizations: Virtual Organizations. Required.
:paramtype virtual_organizations: dict[str, ~generated.models.VOInfo]
:keyword development_settings: Settings for the Development Configuration that can influence
run time. Required.
:paramtype development_settings: ~generated.models.DevelopmentSettings
:keyword gubbins_secrets: Gubbins Secrets. Required.
:paramtype gubbins_secrets: str
"""
super().__init__(**kwargs)
self.virtual_organizations = virtual_organizations
self.development_settings = development_settings
self.gubbins_secrets = gubbins_secrets


class GroupInfo(_serialization.Model):
"""GroupInfo.
Expand Down Expand Up @@ -555,50 +607,6 @@ def __init__(
self.application_status = application_status


class Metadata(_serialization.Model):
"""Metadata.
All required parameters must be populated in order to send to server.
:ivar virtual_organizations: Virtual Organizations. Required.
:vartype virtual_organizations: dict[str, ~generated.models.VOInfo]
:ivar development_settings: Settings for the Development Configuration that can influence run
time. Required.
:vartype development_settings: ~generated.models.DevelopmentSettings
"""

_validation = {
"virtual_organizations": {"required": True},
"development_settings": {"required": True},
}

_attribute_map = {
"virtual_organizations": {"key": "virtual_organizations", "type": "{VOInfo}"},
"development_settings": {
"key": "development_settings",
"type": "DevelopmentSettings",
},
}

def __init__(
self,
*,
virtual_organizations: Dict[str, "_models.VOInfo"],
development_settings: "_models.DevelopmentSettings",
**kwargs: Any,
) -> None:
"""
:keyword virtual_organizations: Virtual Organizations. Required.
:paramtype virtual_organizations: dict[str, ~generated.models.VOInfo]
:keyword development_settings: Settings for the Development Configuration that can influence
run time. Required.
:paramtype development_settings: ~generated.models.DevelopmentSettings
"""
super().__init__(**kwargs)
self.virtual_organizations = virtual_organizations
self.development_settings = development_settings


class SandboxDownloadResponse(_serialization.Model):
"""SandboxDownloadResponse.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.2, generator: @autorest/[email protected])
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.0, generator: @autorest/[email protected])
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand Down
Loading

0 comments on commit 5d9f078

Please sign in to comment.