Skip to content

Commit 94173c5

Browse files
authored
Use root-file, not root as a filetype (#261)
* Fix up confusion in code with "root" and "root-file" use - make it all "root-file" to keep consistent. * More spelling errors corrected
1 parent d4a6556 commit 94173c5

File tree

5 files changed

+38
-33
lines changed

5 files changed

+38
-33
lines changed

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"backend's",
1515
"backends",
1616
"backoff",
17+
"bortles",
1718
"cacheme",
19+
"caplog",
1820
"cernopendata",
1921
"codecov",
2022
"Comming",
@@ -25,6 +27,8 @@
2527
"dont",
2628
"fget",
2729
"fname",
30+
"forkingshirtballs",
31+
"forkit",
2832
"getenv",
2933
"gitlab",
3034
"giveup",
@@ -83,6 +87,7 @@
8387
"SXTYPE",
8488
"SXUSER",
8589
"tcut",
90+
"thegoodplace",
8691
"Topo",
8792
"tqdm",
8893
"unittests",

servicex/config_default.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ default_return_data: parquet
2727
# Easy enough to add a new one here...
2828
backend_types:
2929
- type: xaod
30-
return_data: root
30+
return_data: root-file
3131
- type: uproot
3232
return_data: parquet
3333
- type: cms_run1_aod
34-
return_data: root
34+
return_data: root-file

servicex/data_conversions.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ def __init__(self, default_file_type: str):
2424
self._default_file_type = default_file_type
2525

2626
async def convert_to_pandas(self, file: Path, file_type: Optional[str] = None):
27-
"""Convert to a pandas dataframe from data stored in a file of a particular file_type
27+
"""Convert to a pandas DataFrame from data stored in a file of a particular file_type
2828
2929
Args:
3030
file (Path): Path to the file
3131
file_type (str): What the file contains (root, parquet, etc)
3232
"""
3333
file_type = file_type if file_type is not None else self._default_file_type
34-
if file_type == "root":
34+
if file_type == "root-file":
3535
return await self._convert_root_to_pandas(file)
3636
elif file_type == "parquet":
3737
return await self._convert_parquet_to_pandas(file)
@@ -48,7 +48,7 @@ async def convert_to_awkward(self, file: Path, file_type: Optional[str] = None):
4848
file_type (str): What the file contains (root, parquet, etc)
4949
"""
5050
file_type = file_type if file_type is not None else self._default_file_type
51-
if file_type == "root":
51+
if file_type == "root-file":
5252
return await self._convert_root_to_awkward(file)
5353
elif file_type == "parquet":
5454
return await self._convert_parquet_to_awkward(file)
@@ -59,10 +59,10 @@ async def convert_to_awkward(self, file: Path, file_type: Optional[str] = None):
5959
)
6060

6161
def combine_pandas(self, dfs: Iterable[pd.DataFrame]) -> pd.DataFrame:
62-
"""Combine many pandas dataframes into a single one, in order.
62+
"""Combine many pandas DataFrame into a single one, in order.
6363
6464
Args:
65-
dfs (Iterable[pd.DataFrame]): The list of dataframes
65+
dfs (Iterable[pd.DataFrame]): The list of DataFrames
6666
"""
6767
return pd.concat(dfs)
6868

@@ -84,7 +84,7 @@ async def _convert_root_to_pandas(self, file: Path):
8484
8585
Returns:
8686
87-
DataFrame A pandas dataframe
87+
DataFrame A pandas DataFrame
8888
8989
Note:
9090
@@ -113,7 +113,7 @@ async def _convert_parquet_to_pandas(self, file: Path):
113113
114114
Returns:
115115
116-
DataFrame A pandas dataframe
116+
DataFrame A pandas DataFrame
117117
118118
Note:
119119
@@ -138,14 +138,14 @@ async def _convert_root_to_awkward(self, file: Path):
138138
139139
Returns:
140140
141-
DataFrame A pandas dataframe
141+
DataFrame A pandas DataFrame
142142
143143
Note:
144144
145145
- Work is done on a second thread.
146146
- Awkward is only imported if this is called.
147147
- A LazyArray is returned, so it isn't completely loaded into memory. That also means
148-
this will leak filehandles - as that has to be left open.
148+
this will leak file handles - as that has to be left open.
149149
150150
"""
151151

@@ -169,7 +169,7 @@ async def _convert_parquet_to_awkward(self, file: Path):
169169
170170
Returns:
171171
172-
DataFrame A pandas dataframe
172+
DataFrame A pandas DataFrame
173173
174174
Note:
175175

tests/test_data_conversions.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ def check_pandas_accessible(col):
1616

1717
@pytest.mark.asyncio
1818
async def test_root_to_pandas(good_root_file_path):
19-
df = await DataConverterAdaptor("root").convert_to_pandas(good_root_file_path)
19+
df = await DataConverterAdaptor("root-file").convert_to_pandas(good_root_file_path)
2020
assert isinstance(df, pd.DataFrame)
2121
assert len(df) == 283458
2222
check_pandas_accessible(df["JetPt"])
2323

2424

2525
@pytest.mark.asyncio
2626
async def test_root_to_pandas_default(good_root_file_path):
27-
df = await DataConverterAdaptor("root").convert_to_pandas(
28-
good_root_file_path, "root"
27+
df = await DataConverterAdaptor("root-file").convert_to_pandas(
28+
good_root_file_path, "root-file"
2929
)
3030
assert isinstance(df, pd.DataFrame)
3131
assert len(df) == 283458
3232

3333

3434
@pytest.mark.asyncio
3535
async def test_parquet_to_pandas_non_default(good_uproot_file_path):
36-
df = await DataConverterAdaptor("root").convert_to_pandas(
36+
df = await DataConverterAdaptor("root-file").convert_to_pandas(
3737
good_uproot_file_path, "parquet"
3838
)
3939
assert isinstance(df, pd.DataFrame)
@@ -57,29 +57,29 @@ async def test_parquet_to_awkward(good_uproot_file_path):
5757

5858
@pytest.mark.asyncio
5959
async def test_root_to_awkward(good_root_file_path):
60-
df = await DataConverterAdaptor("root").convert_to_awkward(good_root_file_path)
60+
df = await DataConverterAdaptor("root-file").convert_to_awkward(good_root_file_path)
6161
assert len(df["JetPt"]) == 283458
6262
check_awkward_accessible(df["JetPt"]) # type: ignore
6363

6464

6565
@pytest.mark.asyncio
6666
async def test_to_awkward_fail(good_root_file_path):
6767
with pytest.raises(ServiceXException):
68-
await DataConverterAdaptor("root").convert_to_awkward(
69-
good_root_file_path, "notreally"
68+
await DataConverterAdaptor("root-file").convert_to_awkward(
69+
good_root_file_path, "not-really"
7070
)
7171

7272

7373
@pytest.mark.asyncio
74-
async def test_to_panads_fail(good_root_file_path):
74+
async def test_to_pandas_fail(good_root_file_path):
7575
with pytest.raises(ServiceXException):
76-
await DataConverterAdaptor("root").convert_to_pandas(
77-
good_root_file_path, "notreally"
76+
await DataConverterAdaptor("root-file").convert_to_pandas(
77+
good_root_file_path, "not-really"
7878
)
7979

8080

8181
def test_combine_pandas_from_root(good_root_file_path):
82-
"Load a dataframe from root files and make sure that they work when we ask them to combine"
82+
"Load a DataFrame from root files and make sure that they work when we ask them to combine"
8383

8484
def load_df():
8585
import uproot as uproot
@@ -91,14 +91,14 @@ def load_df():
9191
df1 = load_df()
9292
df2 = load_df()
9393

94-
combined = DataConverterAdaptor("root").combine_pandas([df1, df2])
94+
combined = DataConverterAdaptor("root-file").combine_pandas([df1, df2])
9595

9696
assert len(combined) == len(df1) + len(df2)
9797
check_pandas_accessible(combined["JetPt"])
9898

9999

100100
def test_combine_pandas_from_parquet(good_uproot_file_path):
101-
"Load a dataframe from a parquet file and make sure they work when we ask them to combine"
101+
"Load a DataFrame from a parquet file and make sure they work when we ask them to combine"
102102

103103
def load_df():
104104
import pandas as pd
@@ -108,14 +108,14 @@ def load_df():
108108
df1 = load_df()
109109
df2 = load_df()
110110

111-
combined = DataConverterAdaptor("root").combine_pandas([df1, df2])
111+
combined = DataConverterAdaptor("root-file").combine_pandas([df1, df2])
112112

113113
assert len(combined) == len(df1) + len(df2)
114114
check_pandas_accessible(combined["JetPT"])
115115

116116

117117
def test_combine_awkward_from_root(good_root_file_path):
118-
"Load a dataframe from root files and make sure that they work when we ask them to combine"
118+
"Load a DataFrame from root files and make sure that they work when we ask them to combine"
119119

120120
def load_df():
121121
import uproot as uproot
@@ -127,22 +127,22 @@ def load_df():
127127
df1 = load_df()
128128
df2 = load_df()
129129

130-
combined = DataConverterAdaptor("root").combine_awkward([df1, df2])
130+
combined = DataConverterAdaptor("root-file").combine_awkward([df1, df2])
131131

132132
assert len(combined) == len(df1) + len(df2)
133133
check_awkward_accessible(combined["JetPt"]) # type: ignore
134134

135135

136136
def test_combine_awkward_from_parquet(good_uproot_file_path):
137-
"Load a dataframe from a parquet file and make sure they work when we ask them to combine"
137+
"Load a DataFrame from a parquet file and make sure they work when we ask them to combine"
138138

139139
def load_df():
140140
return ak.from_parquet(good_uproot_file_path) # type: ignore
141141

142142
df1 = load_df()
143143
df2 = load_df()
144144

145-
combined = DataConverterAdaptor("root").combine_awkward([df1, df2])
145+
combined = DataConverterAdaptor("root-file").combine_awkward([df1, df2])
146146

147147
assert len(combined) == len(df1) + len(df2)
148148
check_awkward_accessible(combined["JetPT"]) # type: ignore

tests/test_servicex_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def test_returned_datatype_from_endpoint():
6363
assert x.get_default_returned_datatype("forkit") == "spoons"
6464

6565

66-
def test_defalt_config_has_default_return_datatype():
66+
def test_default_config_has_default_return_datatype():
6767
"Test default settings - default_returned_datatype"
6868
c = ConfigSettings("servicex", "servicex")
6969
assert c["default_return_data"].exists()
7070

7171

72-
def test_defalt_config_has_backend_types():
72+
def test_default_config_has_backend_types():
7373
c = ConfigSettings("servicex", "servicex")
7474
assert c["backend_types"].exists()
7575
count = 0
@@ -151,7 +151,7 @@ def test_sx_adaptor_settings_name_not_type(caplog):
151151
assert len(caplog.record_tuples) == 0
152152

153153

154-
def test_sx_adaptor_settings_name_worng(caplog):
154+
def test_sx_adaptor_settings_name_wrong(caplog):
155155
from confuse import Configuration
156156

157157
c = Configuration("bogus", "bogus")

0 commit comments

Comments
 (0)