diff --git a/.flake8 b/.flake8 index 2e760d89..620de529 100644 --- a/.flake8 +++ b/.flake8 @@ -1,3 +1,3 @@ [flake8] max-line-length = 99 -ignore = W503 +ignore = W503,E704 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7db1c25e..d67169e0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/psf/black - rev: 22.10.0 + rev: 24.10.0 hooks: - id: black diff --git a/servicex/app/transforms.py b/servicex/app/transforms.py index b4fed837..ec433518 100644 --- a/servicex/app/transforms.py +++ b/servicex/app/transforms.py @@ -200,6 +200,7 @@ class TimeFrame(str, Enum): r""" Time Frame levels: 'day', 'week' & 'month' """ + day = ("day",) week = ("week",) month = ("month",) @@ -209,6 +210,7 @@ class LogLevel(str, Enum): r""" Level of the log messages: INFO & ERROR """ + info = ("INFO",) error = ("ERROR",) diff --git a/servicex/databinder_models.py b/servicex/databinder_models.py index ac30b5ab..87d42f51 100644 --- a/servicex/databinder_models.py +++ b/servicex/databinder_models.py @@ -162,9 +162,11 @@ def hash(self): [ self.dataset_identifier.hash, self.NFiles, - self.Query - if (not self.Query or isinstance(self.Query, str)) - else self.Query.generate_selection_string(), + ( + self.Query + if (not self.Query or isinstance(self.Query, str)) + else self.Query.generate_selection_string() + ), self.Codegen, ] ).encode("utf-8") diff --git a/servicex/func_adl/func_adl_dataset.py b/servicex/func_adl/func_adl_dataset.py index 6e951d32..b00e4ce8 100644 --- a/servicex/func_adl/func_adl_dataset.py +++ b/servicex/func_adl/func_adl_dataset.py @@ -51,6 +51,7 @@ class FuncADLQuery(QueryStringGenerator, EventDataset[T], ABC): r""" ServiceX Dataset class that uses func_adl query syntax. """ + # These are methods that are translated locally _execute_locally = ["ResultPandasDF", "ResultAwkwardArray"] default_codegen = None diff --git a/servicex/models.py b/servicex/models.py index b078635b..ed839f4a 100644 --- a/servicex/models.py +++ b/servicex/models.py @@ -136,6 +136,7 @@ class TransformStatus(DocStringBaseModel): r""" Status object returned by servicex """ + model_config = {"use_attribute_docstrings": True} request_id: str @@ -185,6 +186,7 @@ class ResultFile(DocStringBaseModel): r""" Record reporting the properties of a transformed file result """ + model_config = {"use_attribute_docstrings": True} filename: str @@ -197,6 +199,7 @@ class TransformedResults(DocStringBaseModel): Returned for a submission. Gives you everything you need to know about a completed transform. """ + model_config = {"use_attribute_docstrings": True} hash: str diff --git a/tests/test_databinder.py b/tests/test_databinder.py index ffd19f1e..75149521 100644 --- a/tests/test_databinder.py +++ b/tests/test_databinder.py @@ -302,12 +302,15 @@ def test_submit_mapping(transformed_result, codegen_list): } ], } - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): results = deliver(spec, config_path="tests/example_config.yaml") assert list(results["sampleA"]) == ["1.parquet"] @@ -327,12 +330,15 @@ def test_submit_mapping_signed_urls(transformed_result_signed_url, codegen_list) } ], } - with patch( - "servicex.dataset_group.DatasetGroup.as_signed_urls", - return_value=[transformed_result_signed_url], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_signed_urls", + return_value=[transformed_result_signed_url], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): results = deliver(spec, config_path="tests/example_config.yaml") assert list(results["sampleA"]) == [ @@ -354,12 +360,15 @@ def test_submit_mapping_failure(transformed_result, codegen_list): } ] } - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[ServiceXException("dummy")], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[ServiceXException("dummy")], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): results = deliver(spec, config_path="tests/example_config.yaml") assert len(results) == 1 @@ -383,12 +392,15 @@ def test_submit_mapping_failure_signed_urls(codegen_list): } ], } - with patch( - "servicex.dataset_group.DatasetGroup.as_signed_urls", - return_value=[ServiceXException("dummy")], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_signed_urls", + return_value=[ServiceXException("dummy")], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): results = deliver( spec, config_path="tests/example_config.yaml", return_exceptions=False @@ -591,9 +603,10 @@ def test_yaml_include(tmp_path): from servicex.servicex_client import _load_ServiceXSpec # Create two files, one has definitions for the other and is included by it - with open(tmp_path / "definitions.yaml", "w") as f1, open( - path2 := (tmp_path / "parent.yaml"), "w" - ) as f2: + with ( + open(tmp_path / "definitions.yaml", "w") as f1, + open(path2 := (tmp_path / "parent.yaml"), "w") as f2, + ): f1.write( """ - &DEF_query !PythonFunction | @@ -638,12 +651,15 @@ def test_funcadl_query(transformed_result, codegen_list): ] } ) - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): deliver(spec, config_path="tests/example_config.yaml") @@ -667,12 +683,15 @@ def test_query_with_codegen_override(transformed_result, codegen_list): ], } ) - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): with pytest.raises(NameError) as excinfo: deliver(spec, config_path="tests/example_config.yaml") @@ -694,12 +713,15 @@ def test_query_with_codegen_override(transformed_result, codegen_list): ] } ) - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): with pytest.raises(NameError) as excinfo: deliver(spec, config_path="tests/example_config.yaml") @@ -747,12 +769,15 @@ def run_query(input_filenames=None): ] } ) - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): deliver(spec, config_path="tests/example_config.yaml") @@ -772,12 +797,15 @@ def test_uproot_raw_query(transformed_result, codegen_list): ] } ) - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): deliver(spec, config_path="tests/example_config.yaml") @@ -799,12 +827,15 @@ def test_uproot_raw_query_parquet(transformed_result, codegen_list): } ) print(spec) - with patch( - "servicex.dataset_group.DatasetGroup.as_files", - return_value=[transformed_result], - ), patch( - "servicex.servicex_client.ServiceXClient.get_code_generators", - return_value=codegen_list, + with ( + patch( + "servicex.dataset_group.DatasetGroup.as_files", + return_value=[transformed_result], + ), + patch( + "servicex.servicex_client.ServiceXClient.get_code_generators", + return_value=codegen_list, + ), ): deliver(spec, config_path="tests/example_config.yaml") diff --git a/tests/test_func_adl_dataset.py b/tests/test_func_adl_dataset.py index a4239ab8..8dcdfdc9 100644 --- a/tests/test_func_adl_dataset.py +++ b/tests/test_func_adl_dataset.py @@ -74,8 +74,7 @@ def test_type(): class my_type_info: "typespec for possible event type" - def fork_it_over(self) -> int: - ... + def fork_it_over(self) -> int: ... datasource = FuncADLQuery[my_type_info](item_type=my_type_info)