Skip to content

Commit 39ce4f0

Browse files
committed
Fix black formatting
1 parent ec94e0d commit 39ce4f0

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

src/dirac_cwl_proto/metadata/core.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ class DataCatalogInterface(ABC):
6565
"""Abstract interface for data catalog operations."""
6666

6767
@abstractmethod
68-
def get_input_query(self, input_name: str, **kwargs: Any) -> Union[Path, List[Path], None]:
68+
def get_input_query(
69+
self, input_name: str, **kwargs: Any
70+
) -> Union[Path, List[Path], None]:
6971
"""Generate input data query.
7072
7173
Parameters
@@ -157,7 +159,9 @@ def post_process(self, job_path: Path) -> bool:
157159
"""Default post-processing: always succeed."""
158160
return True
159161

160-
def get_input_query(self, input_name: str, **kwargs: Any) -> Union[Path, List[Path], None]:
162+
def get_input_query(
163+
self, input_name: str, **kwargs: Any
164+
) -> Union[Path, List[Path], None]:
161165
"""Default input query: return None."""
162166
return None
163167

@@ -196,7 +200,9 @@ class DataManager(BaseModel):
196200
},
197201
)
198202

199-
metadata_class: str = Field(default="User", description="Registry key for the metadata implementation class")
203+
metadata_class: str = Field(
204+
default="User", description="Registry key for the metadata implementation class"
205+
)
200206

201207
vo: Optional[str] = Field(
202208
default=None,
@@ -206,7 +212,9 @@ class DataManager(BaseModel):
206212
version: Optional[str] = Field(default=None, description="Metadata model version")
207213

208214
# Enhanced fields for submission functionality
209-
query_params: Dict[str, Any] = Field(default_factory=dict, description="Additional parameters for metadata plugins")
215+
query_params: Dict[str, Any] = Field(
216+
default_factory=dict, description="Additional parameters for metadata plugins"
217+
)
210218

211219
def model_copy_with_merge(
212220
self,
@@ -221,7 +229,11 @@ def model_copy_with_merge(
221229
# Handle nested dictionary merging for vo-specific fields
222230
merged_update = {}
223231
for key, value in update.items():
224-
if hasattr(self, key) and isinstance(getattr(self, key), dict) and isinstance(value, dict):
232+
if (
233+
hasattr(self, key)
234+
and isinstance(getattr(self, key), dict)
235+
and isinstance(value, dict)
236+
):
225237
existing_value = getattr(self, key).copy()
226238
existing_value.update(value)
227239
merged_update[key] = existing_value
@@ -285,7 +297,9 @@ def _dash_to_snake(s: str) -> str:
285297
return s.replace("-", "_")
286298

287299
if submitted is None:
288-
descriptor = DataManager(metadata_class=self.metadata_class, **self.query_params)
300+
descriptor = DataManager(
301+
metadata_class=self.metadata_class, **self.query_params
302+
)
289303
return get_registry().instantiate_plugin(descriptor)
290304

291305
# Build inputs from task defaults and parameter overrides
@@ -364,11 +378,17 @@ class JobExecutor(BaseModel):
364378

365379
model_config = ConfigDict(extra="forbid", validate_assignment=True)
366380

367-
platform: Optional[str] = Field(default=None, description="Target platform (e.g., 'DIRAC', 'DIRACX')")
381+
platform: Optional[str] = Field(
382+
default=None, description="Target platform (e.g., 'DIRAC', 'DIRACX')"
383+
)
368384

369-
priority: int = Field(default=10, description="Job priority (higher values = higher priority)")
385+
priority: int = Field(
386+
default=10, description="Job priority (higher values = higher priority)"
387+
)
370388

371-
sites: Optional[List[str]] = Field(default=None, description="Candidate execution sites")
389+
sites: Optional[List[str]] = Field(
390+
default=None, description="Candidate execution sites"
391+
)
372392

373393
@classmethod
374394
def from_cwl_hints(cls: type[T], cwl_object: Any) -> T:

test/test_metadata_core.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ def test_concrete_implementation(self):
6161
"""Test that concrete implementations work correctly."""
6262

6363
class ConcreteCatalog(DataCatalogInterface):
64-
def get_input_query(self, input_name: str, **kwargs: Any) -> Union[Path, List[Path], None]:
64+
def get_input_query(
65+
self, input_name: str, **kwargs: Any
66+
) -> Union[Path, List[Path], None]:
6567
return Path(f"/data/{input_name}")
6668

6769
def get_output_query(self, output_name: str) -> Optional[Path]:
@@ -225,7 +227,9 @@ def test_model_copy_with_merge(self):
225227
descriptor = DataManager(metadata_class="LHCbSimulation", vo="lhcb")
226228

227229
# Test basic update
228-
updated = descriptor.model_copy_with_merge(update={"metadata_class": "NewClass", "new_field": "value"})
230+
updated = descriptor.model_copy_with_merge(
231+
update={"metadata_class": "NewClass", "new_field": "value"}
232+
)
229233

230234
assert updated.metadata_class == "NewClass"
231235
assert updated.vo == "lhcb"
@@ -252,7 +256,9 @@ def test_creation(self):
252256

253257
def test_creation_with_values(self):
254258
"""Test JobExecutor creation with values."""
255-
descriptor = JobExecutor(platform="DIRAC", priority=5, sites=["LCG.CERN.ch", "LCG.IN2P3.fr"])
259+
descriptor = JobExecutor(
260+
platform="DIRAC", priority=5, sites=["LCG.CERN.ch", "LCG.IN2P3.fr"]
261+
)
256262
assert descriptor.platform == "DIRAC"
257263
assert descriptor.priority == 5
258264
assert descriptor.sites == ["LCG.CERN.ch", "LCG.IN2P3.fr"]
@@ -277,7 +283,9 @@ def test_from_cwl_hints(self, mocker):
277283

278284
def test_serialization(self):
279285
"""Test JobExecutor serialization."""
280-
descriptor = JobExecutor(platform="DIRAC", priority=7, sites=["LCG.CERN.ch", "LCG.IN2P3.fr"])
286+
descriptor = JobExecutor(
287+
platform="DIRAC", priority=7, sites=["LCG.CERN.ch", "LCG.IN2P3.fr"]
288+
)
281289

282290
# Test model serialization
283291
data = descriptor.model_dump()
@@ -292,7 +300,9 @@ class TestTransformationDataManager:
292300

293301
def test_creation(self):
294302
"""Test TransformationDataManager creation."""
295-
descriptor = TransformationDataManager(metadata_class="QueryBased", group_size={"input_data": 100})
303+
descriptor = TransformationDataManager(
304+
metadata_class="QueryBased", group_size={"input_data": 100}
305+
)
296306
assert descriptor.metadata_class == "QueryBased"
297307
assert descriptor.group_size == {"input_data": 100}
298308

@@ -314,7 +324,9 @@ def test_inheritance(self):
314324
def test_validation(self):
315325
"""Test group_size validation."""
316326
# Valid group_size
317-
descriptor = TransformationDataManager(metadata_class="User", group_size={"files": 10})
327+
descriptor = TransformationDataManager(
328+
metadata_class="User", group_size={"files": 10}
329+
)
318330
assert descriptor.group_size == {"files": 10}
319331

320332
# Test with no group_size

0 commit comments

Comments
 (0)