Skip to content

Commit

Permalink
Merge branch 'master' into compact-progress-bar
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyisi authored Jan 23, 2025
2 parents 5255f87 + 933ddda commit 0e83a31
Show file tree
Hide file tree
Showing 16 changed files with 171 additions and 308 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
max-line-length = 99
ignore = W503
ignore = W503,E704
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
labels:
- "github-actions"
- "dependencies"
reviewers:
- "BenGalewsky"
- "ponyisi"
12 changes: 6 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.x"

Expand All @@ -35,15 +35,15 @@ jobs:
runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5

- name: Install dependencies
run: |
Expand All @@ -55,7 +55,7 @@ jobs:
coverage run -m pytest tests --cov=./servicex/ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3.1.4
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/reports/
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/ci_production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ jobs:
environment: production-service

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.12
python-version: "3.12"

- name: Save secret
run: 'echo "$SERVICEX_YAML" > servicex.yaml'
shell: bash
env:
SERVICEX_YAML: ${{ secrets.SERVICEX_YAML }}

- name: ServiceX target info
run: grep endpoint servicex.yaml | xxd -ps

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5

- name: Install package
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- 3.0_develop
pull_request:
workflow_dispatch:

Expand All @@ -31,7 +30,7 @@ jobs:
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5

- name: Install Python dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
python-version: '3.12'

- name: Install uv
uses: astral-sh/setup-uv@v3
uses: astral-sh/setup-uv@v5

- name: Install python-build and twine
run: |
Expand Down
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
rev: 22.10.0
rev: 24.10.0
hooks:
- id: black

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ServiceX Client Library


[![GitHub Actions Status](https://github.com/ssl-hep/ServiceX_frontend/workflows/CI/CD/badge.svg?branch=master)](https://github.com/ssl-hep/ServiceX_frontend/actions)
[![GitHub Actions Status](https://github.com/ssl-hep/ServiceX_frontend/actions/workflows/ci.yaml/badge.svg)](https://github.com/ssl-hep/ServiceX_frontend/actions/workflows/ci.yaml?query=branch%3Amaster)
[![Code Coverage](https://codecov.io/gh/ssl-hep/ServiceX_frontend/graph/badge.svg)](https://codecov.io/gh/ssl-hep/ServiceX_frontend)

[![PyPI version](https://badge.fury.io/py/servicex.svg)](https://badge.fury.io/py/servicex)
Expand Down
2 changes: 2 additions & 0 deletions servicex/app/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class TimeFrame(str, Enum):
r"""
Time Frame levels: 'day', 'week' & 'month'
"""

day = ("day",)
week = ("week",)
month = ("month",)
Expand All @@ -209,6 +210,7 @@ class LogLevel(str, Enum):
r"""
Level of the log messages: INFO & ERROR
"""

info = ("INFO",)
error = ("ERROR",)

Expand Down
8 changes: 5 additions & 3 deletions servicex/databinder_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
94 changes: 2 additions & 92 deletions servicex/func_adl/func_adl_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@
Any,
Type,
TypeVar,
cast,
List,
)
from qastle import python_ast_to_text_ast

from func_adl import EventDataset, find_EventDataset
from servicex.query_core import QueryStringGenerator
from servicex.func_adl.util import has_tuple
from abc import ABC

T = TypeVar("T")
Expand All @@ -51,6 +48,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
Expand Down Expand Up @@ -107,95 +105,7 @@ def generate_qastle(self, a: ast.AST) -> str:
Returns:
str: Qastle that should be sent to servicex
"""
top_function = cast(ast.Name, a.func).id
source = a
if top_function in self._execute_locally:
# Request the default type here
default_format = self._ds.first_supported_datatype(
["parquet", "root-ttree"]
)
assert default_format is not None, "Unsupported ServiceX returned format"
method_to_call = self._format_map[default_format]

stream = a.args[0]
col_names = a.args[1]
if method_to_call == "get_data_rootfiles_async":
# If we have no column names, then we must be using a dictionary to
# set them - so just pass that
# directly.
assert isinstance(
col_names, (ast.List, ast.Constant, ast.Str)
), f"Programming error - type name not known {type(col_names).__name__}"
if isinstance(col_names, ast.List) and len(col_names.elts) == 0:
source = stream
else:
source = ast.Call(
func=ast.Name(id="ResultTTree", ctx=ast.Load()),
args=[
stream,
col_names,
ast.Str("treeme"),
ast.Str("junk.root"),
],
)
elif method_to_call == "get_data_parquet_async":
source = stream
# See #32 for why this is commented out
# source = ast.Call(
# func=ast.Name(id='ResultParquet', ctx=ast.Load()),
# args=[stream, col_names, ast.Str('junk.parquet')])
else: # pragma: no cover
# This indicates a programming error
assert False, f"Do not know how to call {method_to_call}"

elif top_function == "ResultParquet":
# Strip off the Parquet function, do a select if there are arguments for column names
source = a.args[0]
col_names = cast(ast.List, a.args[1]).elts

def encode_as_tuple_reference(c_names: List) -> List[ast.AST]:
# Encode each column ref as a index into the tuple we are being passed
return [
ast.Subscript(
value=ast.Name(id="x", ctx=ast.Load()),
slice=ast.Constant(idx),
ctx=ast.Load(),
)
for idx, _ in enumerate(c_names)
]

def encode_as_single_reference():
# Single reference for a bare (non-col) variable
return [
ast.Name(id="x", ctx=ast.Load()),
]

if len(col_names) > 0:
# Add a select on top to set the column names
if len(col_names) == 1:
# Determine if they built a tuple or not
values = (
encode_as_tuple_reference(col_names)
if has_tuple(source)
else encode_as_single_reference()
)
elif len(col_names) > 1:
values = encode_as_tuple_reference(col_names)
else:
assert False, "make sure that type checkers can figure this out"

d = ast.Dict(keys=col_names, values=values)
tup_func = ast.Lambda(
args=ast.arguments(args=[ast.arg(arg="x")]), body=d
)
c = ast.Call(
func=ast.Name(id="Select", ctx=ast.Load()),
args=[source, tup_func],
keywords=[],
)
source = c

return python_ast_to_text_ast(source)
return python_ast_to_text_ast(a)

def as_qastle(self):
r"""
Expand Down
105 changes: 0 additions & 105 deletions servicex/func_adl/util.py

This file was deleted.

Loading

0 comments on commit 0e83a31

Please sign in to comment.