Skip to content

Commit

Permalink
style: ran black with line-length=120
Browse files Browse the repository at this point in the history
  • Loading branch information
fstagni committed Aug 14, 2023
1 parent 024862f commit e9d8b0a
Show file tree
Hide file tree
Showing 38 changed files with 434 additions and 1,110 deletions.
8 changes: 2 additions & 6 deletions src/diracx/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
async def login(
vo: str,
group: Optional[str] = None,
property: Optional[list[str]] = Option(
None, help="Override the default(s) with one or more properties"
),
property: Optional[list[str]] = Option(None, help="Override the default(s) with one or more properties"),
):
scopes = [f"vo:{vo}"]
if group:
Expand Down Expand Up @@ -61,9 +59,7 @@ async def login(
raise RuntimeError("Device authorization flow expired")

CREDENTIALS_PATH.parent.mkdir(parents=True, exist_ok=True)
expires = datetime.now(tz=timezone.utc) + timedelta(
seconds=response.expires_in - EXPIRES_GRACE_SECONDS
)
expires = datetime.now(tz=timezone.utc) + timedelta(seconds=response.expires_in - EXPIRES_GRACE_SECONDS)

Check warning on line 62 in src/diracx/cli/__init__.py

View check run for this annotation

Codecov / codecov/patch

src/diracx/cli/__init__.py#L62

Added line #L62 was not covered by tests
credential_data = {
"access_token": response.access_token,
# TODO: "refresh_token":
Expand Down
10 changes: 2 additions & 8 deletions src/diracx/cli/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def generate_cs(
IdP=IdpConfig(URL=idp_url, ClientID=idp_client_id),
DefaultGroup=user_group,
Users={},
Groups={
user_group: GroupConfig(
JobShare=None, Properties=["NormalUser"], Quota=None, Users=[]
)
},
Groups={user_group: GroupConfig(JobShare=None, Properties=["NormalUser"], Quota=None, Users=[])},
)
config = Config(
Registry={vo: registry},
Expand Down Expand Up @@ -105,7 +101,5 @@ def add_user(
config_data = json.loads(config.json(exclude_unset=True))
yaml_path.write_text(yaml.safe_dump(config_data))
repo.index.add([yaml_path.relative_to(repo_path)])
repo.index.commit(
f"Added user {sub} ({preferred_username}) to vo {vo} and user_group {user_group}"
)
repo.index.commit(f"Added user {sub} ({preferred_username}) to vo {vo} and user_group {user_group}")
typer.echo(f"Successfully added user to {config_repo}", err=True)
8 changes: 2 additions & 6 deletions src/diracx/cli/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,5 @@ def display_rich(data, unit: str) -> None:
@app.async_command()
async def submit(jdl: list[FileText]):
async with Dirac(endpoint="http://localhost:8000") as api:
jobs = await api.jobs.submit_bulk_jobs(
[x.read() for x in jdl], headers=get_auth_headers()
)
print(
f"Inserted {len(jobs)} jobs with ids: {','.join(map(str, (job.job_id for job in jobs)))}"
)
jobs = await api.jobs.submit_bulk_jobs([x.read() for x in jdl], headers=get_auth_headers())
print(f"Inserted {len(jobs)} jobs with ids: {','.join(map(str, (job.job_id for job in jobs)))}")

Check warning on line 108 in src/diracx/cli/jobs.py

View check run for this annotation

Codecov / codecov/patch

src/diracx/cli/jobs.py#L107-L108

Added lines #L107 - L108 were not covered by tests
2 changes: 1 addition & 1 deletion src/diracx/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from ._client import Dirac

try:
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import __all__ as _patch_all
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk
Expand Down
20 changes: 5 additions & 15 deletions src/diracx/client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,18 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self, *, endpoint: str = "", **kwargs: Any
) -> None:
self._config = DiracConfiguration(**kwargs)
self._client: PipelineClient = PipelineClient(
base_url=endpoint, config=self._config, **kwargs
)
self._client: PipelineClient = PipelineClient(base_url=endpoint, config=self._config, **kwargs)

client_models = {
k: v for k, v in _models.__dict__.items() if isinstance(v, type)
}
client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.well_known = WellKnownOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.well_known = WellKnownOperations(self._client, self._config, self._serialize, self._deserialize)
self.auth = AuthOperations( # pylint: disable=abstract-class-instantiated
self._client, self._config, self._serialize, self._deserialize
)
self.config = ConfigOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.jobs = JobsOperations(
self._client, self._config, self._serialize, self._deserialize
)
self.config = ConfigOperations(self._client, self._config, self._serialize, self._deserialize)
self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand Down
24 changes: 6 additions & 18 deletions src/diracx/client/_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,12 @@ def __init__(self, **kwargs: Any) -> None:
self._configure(**kwargs)

def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get(
"user_agent_policy"
) or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(
**kwargs
)
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get(
"logging_policy"
) or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get(
"http_logging_policy"
) or policies.HttpLoggingPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get(
"custom_hook_policy"
) or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(
**kwargs
)
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
4 changes: 1 addition & 3 deletions src/diracx/client/_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
"""
from typing import List

__all__: List[
str
] = [] # Add all objects you want publicly available to users at this package level
__all__: List[str] = [] # Add all objects you want publicly available to users at this package level


def patch_sdk():
Expand Down
Loading

0 comments on commit e9d8b0a

Please sign in to comment.