Skip to content

Commit 2061815

Browse files
authored
Merge pull request #8 from microsoft/virtual_graph
Virtual graph
2 parents 79825f2 + 272c3e0 commit 2061815

178 files changed

Lines changed: 13841 additions & 308 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Publish Python Package to PyPI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "flowquery-py/**"
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- "flowquery-py/**"
14+
release:
15+
types: [published]
16+
workflow_dispatch:
17+
inputs:
18+
target:
19+
description: "Publish target"
20+
required: true
21+
default: "testpypi"
22+
type: choice
23+
options:
24+
- testpypi
25+
- pypi
26+
27+
jobs:
28+
build:
29+
name: Build distribution
30+
runs-on: ubuntu-latest
31+
defaults:
32+
run:
33+
working-directory: flowquery-py
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up Python
39+
uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
43+
- name: Install build dependencies
44+
run: pip install build
45+
46+
- name: Build package
47+
run: python -m build
48+
49+
- name: Upload distribution artifacts
50+
uses: actions/upload-artifact@v4
51+
with:
52+
name: python-package-distributions
53+
path: flowquery-py/dist/
54+
55+
publish-testpypi:
56+
name: Publish to TestPyPI
57+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi'
58+
needs: build
59+
runs-on: ubuntu-latest
60+
environment:
61+
name: testpypi
62+
url: https://test.pypi.org/p/flowquery
63+
permissions:
64+
id-token: write
65+
66+
steps:
67+
- name: Download distribution artifacts
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
73+
- name: Publish to TestPyPI
74+
uses: pypa/gh-action-pypi-publish@release/v1
75+
with:
76+
repository-url: https://test.pypi.org/legacy/
77+
78+
publish-pypi:
79+
name: Publish to PyPI
80+
if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'pypi')
81+
needs: build
82+
runs-on: ubuntu-latest
83+
environment:
84+
name: pypi
85+
url: https://pypi.org/p/flowquery
86+
permissions:
87+
id-token: write
88+
89+
steps:
90+
- name: Download distribution artifacts
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: python-package-distributions
94+
path: dist/
95+
96+
- name: Publish to PyPI
97+
uses: pypa/gh-action-pypi-publish@release/v1

flowquery-py/.gitignore

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
27+
# PyInstaller
28+
*.manifest
29+
*.spec
30+
31+
# Installer logs
32+
pip-log.txt
33+
pip-delete-this-directory.txt
34+
35+
# Unit test / coverage reports
36+
htmlcov/
37+
.tox/
38+
.nox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*.cover
45+
*.py,cover
46+
.hypothesis/
47+
.pytest_cache/
48+
49+
# Environments
50+
.env
51+
.venv
52+
env/
53+
venv/
54+
ENV/
55+
env.bak/
56+
venv.bak/
57+
58+
# IDE
59+
.idea/
60+
.vscode/
61+
*.swp
62+
*.swo
63+
*~
64+
.project
65+
.pydevproject
66+
.settings/
67+
68+
# Jupyter Notebook
69+
.ipynb_checkpoints
70+
71+
# mypy
72+
.mypy_cache/
73+
.dmypy.json
74+
dmypy.json
75+
76+
# Pyre type checker
77+
.pyre/
78+
79+
# pytype static type analyzer
80+
.pytype/
81+
82+
# OS
83+
.DS_Store
84+
Thumbs.db

flowquery-py/README.md

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
# FlowQuery Python Implementation
2+
3+
This is the Python implementation of FlowQuery, a declarative query language for data processing pipelines.
4+
5+
## Installation
6+
7+
### From Source
8+
9+
```bash
10+
git clone https://github.com/microsoft/FlowQuery.git
11+
cd FlowQuery/flowquery-py
12+
pip install -e .
13+
```
14+
15+
### With Development Dependencies
16+
17+
```bash
18+
pip install -e ".[dev]"
19+
```
20+
21+
## Quick Start
22+
23+
### Command Line Interface
24+
25+
After installation, you can start the interactive REPL:
26+
27+
```bash
28+
flowquery
29+
```
30+
31+
### Using Conda (Alternative)
32+
33+
**Windows (PowerShell):**
34+
35+
```powershell
36+
cd flowquery-py
37+
.\setup_env.ps1
38+
conda activate flowquery
39+
```
40+
41+
**Linux/macOS:**
42+
43+
```bash
44+
cd flowquery-py
45+
chmod +x setup_env.sh
46+
./setup_env.sh
47+
conda activate flowquery
48+
```
49+
50+
The setup scripts automatically:
51+
52+
1. Read the Python version from `pyproject.toml`
53+
2. Create a conda environment named `flowquery`
54+
3. Install the package with all dev dependencies
55+
56+
## Requirements
57+
58+
- Python 3.10+ (defined in `pyproject.toml`)
59+
- pytest (for running tests)
60+
- pytest-asyncio (for async test support)
61+
- aiohttp (for HTTP requests)
62+
63+
All dependencies are managed in `pyproject.toml`.
64+
65+
## Programmatic Usage
66+
67+
```python
68+
import asyncio
69+
from flowquery import Runner
70+
71+
runner = Runner("WITH 1 as x RETURN x + 1 as result")
72+
asyncio.run(runner.run())
73+
print(runner.results) # [{'result': 2}]
74+
```
75+
76+
## Running Tests
77+
78+
```bash
79+
pytest tests/
80+
```
81+
82+
## Project Structure
83+
84+
```
85+
flowquery-py/
86+
├── pyproject.toml # Dependencies & project config (single source of truth)
87+
├── setup_env.ps1 # Windows conda setup script
88+
├── setup_env.sh # Linux/macOS conda setup script
89+
├── README.md
90+
├── src/
91+
│ ├── __init__.py # Main package entry point
92+
│ ├── extensibility.py # Public API for custom functions
93+
│ ├── compute/
94+
│ │ └── runner.py # Query execution engine
95+
│ ├── graph/
96+
│ │ ├── node.py # Graph node representation
97+
│ │ ├── relationship.py # Graph relationship representation
98+
│ │ ├── pattern.py # Pattern matching
99+
│ │ └── database.py # In-memory graph database
100+
│ ├── io/
101+
│ │ └── command_line.py # Interactive REPL
102+
│ ├── parsing/
103+
│ │ ├── parser.py # Main parser
104+
│ │ ├── ast_node.py # AST node base class
105+
│ │ ├── expressions/ # Expression types (numbers, strings, operators)
106+
│ │ ├── functions/ # Built-in and custom functions
107+
│ │ ├── operations/ # Query operations (WITH, RETURN, UNWIND, etc.)
108+
│ │ ├── components/ # LOAD clause components
109+
│ │ ├── data_structures/ # Arrays, objects, lookups
110+
│ │ └── logic/ # CASE/WHEN/THEN/ELSE
111+
│ ├── tokenization/
112+
│ │ ├── tokenizer.py # Lexer
113+
│ │ ├── token.py # Token class
114+
│ │ └── ... # Token types and mappers
115+
│ └── utils/
116+
│ ├── string_utils.py # String manipulation utilities
117+
│ └── object_utils.py # Object utilities
118+
└── tests/
119+
├── test_extensibility.py
120+
├── compute/
121+
│ └── test_runner.py
122+
├── graph/
123+
│ ├── test_create.py
124+
│ ├── test_data.py
125+
│ └── test_match.py
126+
├── parsing/
127+
│ ├── test_parser.py
128+
│ ├── test_context.py
129+
│ └── test_expression.py
130+
└── tokenization/
131+
├── test_tokenizer.py
132+
├── test_token_mapper.py
133+
└── test_trie.py
134+
```
135+
136+
## Creating Custom Functions
137+
138+
```python
139+
from flowquery.extensibility import Function, FunctionDef
140+
141+
@FunctionDef({
142+
"description": "Converts a string to uppercase",
143+
"category": "string",
144+
"parameters": [
145+
{"name": "text", "description": "String to convert", "type": "string"}
146+
],
147+
"output": {"description": "Uppercase string", "type": "string"}
148+
})
149+
class UpperCase(Function):
150+
def __init__(self):
151+
super().__init__("uppercase")
152+
self._expected_parameter_count = 1
153+
154+
def value(self) -> str:
155+
return str(self.get_children()[0].value()).upper()
156+
```
157+
158+
## License
159+
160+
MIT License - see [LICENSE](LICENSE) for details.
161+
162+
## Links
163+
164+
- [Homepage](https://github.com/microsoft/FlowQuery/flowquery-py)
165+
- [Repository](https://github.com/microsoft/FlowQuery/flowquery-py)
166+
- [Issues](https://github.com/microsoft/FlowQuery/issues)

0 commit comments

Comments
 (0)