Skip to content
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 25.12.0
rev: 26.1.0
hooks:
- id: black

Expand Down
1 change: 0 additions & 1 deletion examples/FuncADL_Uproot_Dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from servicex import query, dataset, deliver


spec = {
"Sample": [
{
Expand Down
3 changes: 1 addition & 2 deletions examples/FuncADL_Uproot_Typed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from servicex import Sample, ServiceXSpec, query, dataset, deliver


spec = ServiceXSpec(
Sample=[
Sample(
Expand All @@ -16,7 +15,7 @@
.FromTree("CollectionTree")
.Select(
lambda e: {"el_pt": e["AnalysisElectronsAuxDyn.pt"]}
), # type:ignore
), # type: ignore
)
]
)
Expand Down
1 change: 0 additions & 1 deletion examples/TopCP_Dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from servicex import query, dataset, deliver


spec = {
"Sample": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/TopCP_Typed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from servicex import Sample, ServiceXSpec, query, dataset, deliver


spec = ServiceXSpec(
Sample=[
Sample(
Expand Down
1 change: 0 additions & 1 deletion examples/UprootRaw_Dict.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from servicex import query, dataset, deliver


spec = {
"Sample": [
{
Expand Down
1 change: 0 additions & 1 deletion examples/UprootRaw_Typed.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from servicex import Sample, ServiceXSpec, query, dataset, deliver


spec = ServiceXSpec(
Sample=[
Sample(
Expand Down
1 change: 0 additions & 1 deletion servicex/app/cli_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import typer


backend_cli_option = typer.Option(
None, "-b", "--backend", help="Name of backend server from .servicex file"
)
Expand Down
6 changes: 2 additions & 4 deletions servicex/app/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,14 @@ def run(
# Write configuration file
config_path = Path.cwd() / "servicex.yaml"
with open(config_path, "w") as file:
file.write(
f"""api_endpoints:
file.write(f"""api_endpoints:
- endpoint: {url}
name: {service_name}
{"token: " + str(token) if not auth_disabled else ""}

cache_path: {downloads_path}
shortened_downloaded_filename: true
"""
)
""")

# Success message
console.print()
Expand Down
1 change: 0 additions & 1 deletion servicex/dataset/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,4 @@
XRootDDatasetIdentifier as XRootD,
)


__any__ = ["Rucio", "FileList", "CERNOpenData", "GenericDataSet", "XRootD"]
1 change: 0 additions & 1 deletion servicex/dataset_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
from servicex.models import TransformedResults, ResultFormat
from make_it_sync import make_sync


DatasetGroupMember = Query


Expand Down
1 change: 0 additions & 1 deletion servicex/expandable_progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
TaskID,
)


DEFAULT_STYLE = [
TextColumn("[progress.description]{task.description}"),
BarColumn(complete_style="rgb(114,156,31)", finished_style="rgb(0,255,0)"),
Expand Down
5 changes: 1 addition & 4 deletions tests/app/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ def test_codegen_list(script_runner):
["servicex", "codegen", "list", "-c", "tests/example_config.yaml"]
)
assert result.returncode == 0
assert (
result.stdout
== """{
assert result.stdout == """{
"uproot": "http://uproot-codegen",
"xaod": "http://xaod-codegen"
}
"""
)
12 changes: 4 additions & 8 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ def test_read_from_home(monkeypatch, tmp_path):
home = tmp_path / "home"
home.mkdir()
cfg = home / "servicex.yaml"
cfg.write_text(
"""
cfg.write_text("""
api_endpoints:
- endpoint: http://localhost:5000
name: localhost
"""
)
""")

# Patch Path.home to point to our fake home and move cwd elsewhere
monkeypatch.setattr(Path, "home", lambda: home)
Expand All @@ -103,13 +101,11 @@ def test_read_from_default_files(monkeypatch, tmp_path, config_filename):

# Create a fake home directory with the config file
cfg = tmp_path / config_filename
cfg.write_text(
"""
cfg.write_text("""
api_endpoints:
- endpoint: http://localhost:5012
name: localhost
"""
)
""")

monkeypatch.chdir(tmp_path)

Expand Down
48 changes: 16 additions & 32 deletions tests/test_databinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ def test_yaml(tmp_path):

# Nominal paths
with open(path := (tmp_path / "python.yaml"), "w") as f:
f.write(
"""
f.write("""
General:
OutputFormat: root-ttree
Delivery: LocalCache
Expand Down Expand Up @@ -477,8 +476,7 @@ def run_query(input_filenames=None):
- Name: ttH8
Dataset: !Rucio user.kchoi:user.kchoi.fcnc_tHq_ML.ttH.v113
Query: !TopCP 'reco="examples/reco.yaml"'
"""
)
""")
f.flush()
result = _load_ServiceXSpec(path)
assert type(result.Sample[0].Query).__name__ == "PythonFunction"
Expand Down Expand Up @@ -508,8 +506,7 @@ def run_query(input_filenames=None):

# Python syntax error
with open(path := (tmp_path / "python.yaml"), "w") as f:
f.write(
"""
f.write("""
General:
OutputFormat: root-ttree
Delivery: LocalCache
Expand All @@ -520,16 +517,14 @@ def run_query(input_filenames=None):
Query: !PythonFunction |
def run_query(input_filenames=None):
i ==== 18 # syntax error
"""
)
""")
f.flush()
with pytest.raises(SyntaxError):
_load_ServiceXSpec(path)

# Duplicate samples with different names but same dataset and query
with open(path := (tmp_path / "python.yaml"), "w") as f:
f.write(
"""
f.write("""
General:
OutputFormat: root-ttree
Delivery: LocalCache
Expand All @@ -545,17 +540,15 @@ def run_query(input_filenames=None):
- Name: ttH5
Dataset: !FileList ["/path/to/file1.root", "/path/to/file2.root"]
Query: !UprootRaw '[{"treename": "nominal"}]'
"""
)
""")
f.flush()
with pytest.raises(RuntimeError):
_load_ServiceXSpec(path)

# Duplicate samples with different names but same datasets (multiple) and query
# change the order of the datasets
with open(path := (tmp_path / "python.yaml"), "w") as f:
f.write(
"""
f.write("""
General:
OutputFormat: root-ttree
Delivery: LocalCache
Expand All @@ -571,17 +564,15 @@ def run_query(input_filenames=None):
- Name: ttH5
Dataset: !FileList ["/path/to/file1.root", "/path/to/file2.root"]
Query: !UprootRaw '[{"treename": "nominal"}]'
"""
)
""")
f.flush()
with pytest.raises(RuntimeError):
_load_ServiceXSpec(path)

# Samples with different names but same datasets(multiple) and query
# different NFiles
with open(path := (tmp_path / "python.yaml"), "w") as f:
f.write(
"""
f.write("""
General:
OutputFormat: root-ttree
Delivery: LocalCache
Expand All @@ -595,8 +586,7 @@ def run_query(input_filenames=None):
NFiles: 1
Dataset: !FileList ["/path/to/file1.root", "/path/to/file2.root"]
Query: !UprootRaw '[{"treename": "nominal"}]'
"""
)
""")
f.flush()
result = _load_ServiceXSpec(path)
assert type(result.Sample[0].Query).__name__ == "UprootRawQuery"
Expand All @@ -605,8 +595,7 @@ def run_query(input_filenames=None):
# Samples with different names but same datasets(multiple) and
# different queries
with open(path := (tmp_path / "python.yaml"), "w") as f:
f.write(
"""
f.write("""
General:
OutputFormat: root-ttree
Delivery: LocalCache
Expand All @@ -618,8 +607,7 @@ def run_query(input_filenames=None):
- Name: ttH6
Dataset: !FileList ["/path/to/file1.root", "/path/to/file2.root"]
Query: !UprootRaw '[{"treename": "CollectionTree"}]'
"""
)
""")
f.flush()
result = _load_ServiceXSpec(path)
assert type(result.Sample[0].Query).__name__ == "UprootRawQuery"
Expand All @@ -634,15 +622,12 @@ def test_yaml_include(tmp_path):
open(tmp_path / "definitions.yaml", "w") as f1,
open(path2 := (tmp_path / "parent.yaml"), "w") as f2,
):
f1.write(
"""
f1.write("""
- &DEF_query !PythonFunction |
def run_query(input_filenames=None):
return []
"""
)
f2.write(
"""
""")
f2.write("""
Definitions:
!include definitions.yaml

Expand All @@ -654,8 +639,7 @@ def run_query(input_filenames=None):
- Name: ttH
RucioDID: user.kchoi:user.kchoi.fcnc_tHq_ML.ttH.v11
Query: *DEF_query
"""
)
""")
f1.flush()
f2.flush()
_load_ServiceXSpec(path2)
Expand Down
6 changes: 2 additions & 4 deletions tests/test_servicex_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,9 @@ async def test_get_transforms_wlcg_bearer_token(
}
post.return_value.__aenter__.return_value.status = 401
token_file = tempfile.NamedTemporaryFile(mode="w+t", delete=False)
token_file.write(
""""
token_file.write(""""
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c
"""
)
""")
token_file.close()

with patch.dict(os.environ, {"BEARER_TOKEN_FILE": token_file.name}):
Expand Down
18 changes: 6 additions & 12 deletions tests/test_topcp_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,10 @@
def test_default_keys():
with tempfile.NamedTemporaryFile(mode="w", delete=False) as fp:
test_logfile_path = Path(fp.name)
fp.write(
"""
fp.write("""
CommonServices:
runSystematics: False
"""
)
""")
fp.close()

topcp_query = TopCPQuery(reco=test_logfile_path)
Expand All @@ -67,8 +65,7 @@ def test_yaml_serialization():
tempfile.NamedTemporaryFile(mode="w", delete=False) as f2,
):
test_parton_yaml = Path(f1.name)
f1.write(
"""
f1.write("""
CommonServices:
systematicsHistogram: 'listOfSystematicsPartonLevel'
runSystematics: True
Expand All @@ -77,12 +74,10 @@ def test_yaml_serialization():

PartonHistory:
- histories: 'Ttbar'
"""
)
""")
f1.close()
test_particle_yaml = Path(f2.name)
f2.write(
"""
f2.write("""
CommonServices:
systematicsHistogram: 'listOfSystematicsParticleLevel'
runSystematics: True
Expand All @@ -95,8 +90,7 @@ def test_yaml_serialization():
useDressedProperties: True
minPt: 25000.0
maxEta: 2.5
"""
)
""")
f2.close()

topcp_query = TopCPQuery(parton=test_parton_yaml, particle=test_particle_yaml)
Expand Down