Skip to content

Commit 3909fdc

Browse files
committed
Adding readme comments
1 parent b86f070 commit 3909fdc

File tree

2 files changed

+94
-8
lines changed

2 files changed

+94
-8
lines changed

.vscode/settings.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@
44
"python.linting.flake8Enabled": true,
55
"cSpell.words": [
66
"AST's",
7-
"Dlib",
8-
"Jupyter",
9-
"LINQ",
10-
"ROOTT",
11-
"Topo",
127
"asts",
138
"astunparse",
149
"asyncio",
10+
"backends",
1511
"bdist",
1612
"codecov",
1713
"databanks",
1814
"dataframes",
15+
"Dlib",
1916
"elts",
2017
"getenv",
2118
"gwatts",
2219
"iscoroutine",
20+
"Jupyter",
21+
"LINQ",
2322
"localds",
2423
"macos",
2524
"nargs",
@@ -30,10 +29,12 @@
3029
"pypi",
3130
"pytest",
3231
"qastle",
32+
"ROOTT",
3333
"rucio",
3434
"sdist",
3535
"servicex",
3636
"setuptools",
37+
"Topo",
3738
"unittests",
3839
"url's",
3940
"xaod",

README.md

Lines changed: 88 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,96 @@ and returns them in a columnar format. It is currently used as a central part of
1414
This is the base package that has the backend-agnostic code to query hierarchical data. In all likelihood you will want to install
1515
one of the following packages:
1616

17-
- func_adl.xAOD: for running on an ATLAS experiment xAOD file hosted in ServiceX
17+
- func_adl_xAOD: for running on an ATLAS & CMS experiment xAOD file hosted in ServiceX
18+
- func_adl_uproot: for running on flat root files
1819
- func_adl.xAOD.backend: for running on a local file using docker
1920

20-
See the documentation for more information.
21+
See the documentation for more information on what expressions and capabilities are possible in each of these backends.
22+
23+
## Extensibility
24+
25+
There are two several extensibility points:
26+
27+
- `EventDataset` should be sub-classed to provide an executor.
28+
- `EventDataset` can use Python's type system to allow for editors and other intelligent typing systems to type check expressions. The more type data present, the more the system can help.
29+
- It is possible to insert a call back at a function or method call site that will allow for modification of the `ObjectStream` or the call site's `ast`.
30+
31+
### EventDataSet
32+
33+
An example `EventDataSet`:
34+
35+
```python
36+
class events(EventDataset):
37+
async def execute_result_async(self, a: ast.AST, title: Optional[str] = None):
38+
await asyncio.sleep(0.01)
39+
return a
40+
```
41+
42+
and some `func_adl` code that uses it:
43+
44+
```python
45+
r = (events()
46+
.SelectMany(lambda e: e.Jets('jets'))
47+
.Select(lambda j: j.eta())
48+
.value())
49+
```
50+
51+
- When the `.value()` method is invoked, the `execute_result_async` with a complete `ast` representing the query is called. This is the point that one would send it to the backend to actually be processed.
52+
- Normally, the constructor of `events` would take in the name of the dataset to be processed, which could then be used in `execute_result_async`.
53+
54+
### Typing EventDataset
55+
56+
A minor change to the declaration above, and no change to the query:
57+
58+
```python
59+
class dd_jet:
60+
def pt(self) -> float:
61+
...
62+
63+
def eta(self) -> float:
64+
...
65+
66+
class dd_event:
67+
def Jets(self, bank: str) -> Iterable[dd_jet]:
68+
...
69+
70+
def EventNumber(self, bank='default') -> int
71+
...
72+
73+
class events(EventDataset[dd_event]):
74+
async def execute_result_async(self, a: ast.AST, title: Optional[str] = None):
75+
await asyncio.sleep(0.01)
76+
return a
77+
```
78+
79+
This is not required, but when this is done:
80+
81+
- Editors that use types to give one a list of options/guesses will now light up as long as they have reasonable type-checking built in.
82+
- If a required argument is missed, an error will be generated
83+
- If a default argument is missed, it will be automatically filled in.
84+
85+
It should be noted that the type and expression follower is not very sophisticated! While it can follow method calls, it won't follow much else!
86+
87+
### Type-based callbacks
88+
89+
By adding a function and a reference in the type system, arbitrary code can be executed during the traversing of the `func_adl`. Keeping the query the same and the `events` definition the same, we can add the info directly to the python type declarations:
90+
91+
```python
92+
def add_md_for_type(s: ObjectStream[T], a: ast.Call) -> Tuple[ObjectStream[T], ast.AST]:
93+
return s.MetaData({'hi': 'there'}), a
94+
95+
96+
class dd_event:
97+
_func_adl_type_info = add_md_for_type
98+
99+
def Jets(self, bank: str) -> Iterable[dd_jet]:
100+
...
101+
```
102+
103+
- When the `.Jets()` method is processed, the `add_md_for_type` is called with the current object stream and the ast.
104+
- `add_md_for_type` here adds metadata and returns the updated stream and ast.
105+
- Nothing prevents the function from parsing the AST, removing or adding arguments, adding more complex metadata, or doing any of this depending on the arguments in the call site.
21106

22107
## Development
23108

24-
After a new release has been built and passes the tests you can release it by creating a new release on `github`. An action that runs when a release is "created" will send it to `pypi`.
109+
After a new release has been built and passes the tests you can release it by creating a new release on `github`. An action that runs when a release is "created" will send it to `pypi`.

0 commit comments

Comments
 (0)