Skip to content

Commit 683094c

Browse files
authored
Initial commit
0 parents  commit 683094c

12 files changed

+953
-0
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
name: Bug Report
3+
about: Share your findings to help us squash those bugs
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**What kind of bug is it?**
11+
- [ ] Xircuits Component Library Code
12+
- [ ] Workflow Example
13+
- [ ] Documentation
14+
- [ ] Not Sure
15+
16+
**Xircuits Version**
17+
Run `pip show xircuits` to get the version, or mention you've used a specific .whl from a branch.
18+
19+
**Describe the bug**
20+
A clear and concise description of what the bug is.
21+
22+
**To Reproduce**
23+
Steps to reproduce the behavior:
24+
1. Go to '...'
25+
2. Click on '....'
26+
3. Scroll down to '....'
27+
4. See error
28+
29+
**Expected behavior**
30+
A clear and concise description of what you expected to happen.
31+
32+
**Screenshots**
33+
If applicable, add screenshots to help explain your problem.
34+
35+
**Tested on?**
36+
37+
- [ ] Windows
38+
- [ ] Linux Ubuntu
39+
- [ ] Centos
40+
- [ ] Mac
41+
- [ ] Others (State here -> xxx )
42+
43+
**Additional context**
44+
Add any other context about the problem here.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Feature Request
3+
about: Suggest an idea for this component library
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Xircuits Version**
11+
Run `pip show xircuits` to get the version, or mention you've used a specific .whl from a branch.
12+
13+
**What kind of feature is it?**
14+
- [ ] Xircuits Component Library Code
15+
- [ ] Workflow Example
16+
- [ ] Documentation
17+
- [ ] Not Sure
18+
19+
**Is your feature request related to a problem? Please describe.**
20+
21+
A clear and concise description of what the problem is. Ex. When I use X feature / when I do Y it does Z.
22+
23+
**Describe the solution you'd like**
24+
25+
A clear and concise description of what you want to happen.
26+
27+
**Describe alternatives you've considered**
28+
A clear and concise description of any alternative solutions or features you've considered.
29+
30+
**Additional context**
31+
Add any other context or screenshots about the feature request here.

.github/PULL_REQUEST_TEMPLATE.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
Welcome to Xircuits! Thank you for making a pull request. Please ensure that your pull request follows the template.
2+
3+
# Description
4+
5+
Please include a summary which includes relevant motivation and context. You may also describe the code changes. List any dependencies that are required for this change.
6+
7+
## References
8+
9+
If applicable, note issue numbers this pull request addresses. You can also note any other pull requests that address this issue and how this pull request is different.
10+
11+
## Pull Request Type
12+
13+
- [ ] Xircuits Component Library Code
14+
- [ ] Workflow Example
15+
- [ ] Documentation
16+
- [ ] Others (Please Specify)
17+
18+
## Type of Change
19+
20+
- [ ] New feature (non-breaking change which adds functionality)
21+
- [ ] Bug fix (non-breaking change which fixes an issue)
22+
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
23+
- [ ] This change requires a documentation update
24+
25+
# Tests
26+
27+
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
28+
29+
**1. Test A**
30+
31+
1. First step
32+
2. Second step
33+
3. ...
34+
35+
36+
## Tested on?
37+
38+
- [ ] Windows
39+
- [ ] Linux Ubuntu
40+
- [ ] Centos
41+
- [ ] Mac
42+
- [ ] Others (State here -> xxx )
43+
44+
# Notes
45+
46+
Add if any.
+117
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: Run Xircuits Workflows Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: "*"
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-run:
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
python-version: ["3.9", "3.10", "3.11"]
17+
env:
18+
TEST_XIRCUITS: |
19+
example.xircuits
20+
steps:
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Create virtual environment
30+
run: |
31+
python -m venv venv
32+
echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH
33+
34+
- name: Install xircuits in virtual environment
35+
run: pip install xircuits
36+
37+
- name: Set Environment Variables
38+
run: |
39+
LIBRARY_NAME=$(echo "${GITHUB_REPOSITORY##*/}" | sed 's/-/_/g')
40+
echo "LIBRARY_NAME=$LIBRARY_NAME" >> $GITHUB_ENV
41+
COMPONENT_LIBRARY_PATH="xai_components/${LIBRARY_NAME}"
42+
echo "COMPONENT_LIBRARY_PATH=$COMPONENT_LIBRARY_PATH" >> $GITHUB_ENV
43+
if [ "${{ github.event_name }}" == "pull_request" ]; then
44+
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
45+
else
46+
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
47+
fi
48+
49+
- name: List Xircuits
50+
run: xircuits list
51+
52+
- name: Clone Repository
53+
run: |
54+
rm -rf ${{ env.COMPONENT_LIBRARY_PATH }}
55+
if [ "${{ github.event_name }}" == "pull_request" ]; then
56+
REPO_URL="${{ github.event.pull_request.head.repo.clone_url }}"
57+
else
58+
REPO_URL="https://github.com/${{ github.repository }}"
59+
fi
60+
git clone -b ${{ env.BRANCH_NAME }} $REPO_URL ${{ env.COMPONENT_LIBRARY_PATH }}
61+
62+
- name: Install Component Library
63+
run: |
64+
if [ -f "${{ env.COMPONENT_LIBRARY_PATH }}/requirements.txt" ]; then
65+
echo "requirements.txt found, installing dependencies..."
66+
pip install -r ${{ env.COMPONENT_LIBRARY_PATH }}/requirements.txt
67+
else
68+
echo "requirements.txt not found."
69+
fi
70+
71+
- name: Test .xircuits Workflows
72+
run: |
73+
export PYTHONPATH="${GITHUB_WORKSPACE}:${PYTHONPATH}"
74+
LOG_FILE="${GITHUB_WORKSPACE}/workflow_logs.txt"
75+
TEST_FILES=$(echo "$TEST_XIRCUITS" | tr '\n' ' ')
76+
echo "Repository: $LIBRARY_NAME" > $LOG_FILE
77+
echo "Branch: $BRANCH_NAME" >> $LOG_FILE
78+
echo -e "Testing Files:\n$TEST_FILES" >> $LOG_FILE
79+
IFS=' ' read -r -a FILE_ARRAY <<< "$TEST_FILES"
80+
FAIL=0
81+
if [ ${#FILE_ARRAY[@]} -eq 0 ]; then
82+
echo "No .xircuits files specified for testing." | tee -a $LOG_FILE
83+
else
84+
for file in "${FILE_ARRAY[@]}"; do
85+
FULL_PATH="${COMPONENT_LIBRARY_PATH}/${file}"
86+
if [ -f "$FULL_PATH" ]; then
87+
WORKFLOW_LOG_FILE="${FULL_PATH%.*}_workflow_log.txt"
88+
echo -e "\n\nProcessing $FULL_PATH..." | tee -a $LOG_FILE
89+
xircuits compile $FULL_PATH "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE
90+
python "${FULL_PATH%.*}.py" 2>&1 | tee -a $WORKFLOW_LOG_FILE
91+
LAST_LINE=$(tail -n 1 "$WORKFLOW_LOG_FILE")
92+
if [[ "$LAST_LINE" != "Finished Executing" ]]; then
93+
echo "Error: Workflow $FULL_PATH did not finish as expected" | tee -a $LOG_FILE
94+
FAIL=1
95+
else
96+
echo "$FULL_PATH processed successfully" | tee -a $LOG_FILE
97+
fi
98+
cat "$WORKFLOW_LOG_FILE" | tee -a $LOG_FILE
99+
else
100+
echo "Specified file $FULL_PATH does not exist" | tee -a $LOG_FILE
101+
FAIL=1
102+
fi
103+
done
104+
fi
105+
if [ $FAIL -ne 0 ]; then
106+
echo "One or more workflows failed or did not finish as expected." | tee -a $LOG_FILE
107+
exit 1
108+
else
109+
echo "Workflow processing completed" | tee -a $LOG_FILE
110+
fi
111+
112+
- name: Upload log file
113+
if: always()
114+
uses: actions/upload-artifact@v4
115+
with:
116+
name: ${{ env.LIBRARY_NAME }}-validation-workflow-${{ matrix.python-version }}
117+
path: ${{ github.workspace }}/workflow_logs.txt

.gitignore

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/

0 commit comments

Comments
 (0)