Skip to content

Commit ee8175f

Browse files
committed
Component library maintenance
1 parent a8c1d16 commit ee8175f

File tree

7 files changed

+516
-186
lines changed

7 files changed

+516
-186
lines changed

.github/ISSUE_TEMPLATE/bug-report.md

Lines changed: 44 additions & 0 deletions
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.
Lines changed: 31 additions & 0 deletions
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

Lines changed: 46 additions & 0 deletions
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.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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+
examples/gemini_example.xircuits
20+
21+
steps:
22+
- name: Checkout Repository
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Create virtual environment
31+
run: |
32+
python -m venv venv
33+
echo "${{ github.workspace }}/venv/bin" >> $GITHUB_PATH
34+
35+
- name: Install xircuits in virtual environment
36+
run: pip install xircuits
37+
38+
- name: Set Environment Variables
39+
run: |
40+
LIBRARY_NAME=$(echo "${GITHUB_REPOSITORY##*/}" | sed 's/-/_/g')
41+
echo "LIBRARY_NAME=$LIBRARY_NAME" >> $GITHUB_ENV
42+
COMPONENT_LIBRARY_PATH="xai_components/${LIBRARY_NAME}"
43+
echo "COMPONENT_LIBRARY_PATH=$COMPONENT_LIBRARY_PATH" >> $GITHUB_ENV
44+
if [ "${{ github.event_name }}" == "pull_request" ]; then
45+
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
46+
else
47+
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
48+
fi
49+
50+
- name: List Xircuits
51+
run: xircuits list
52+
53+
- name: Clone Repository
54+
run: |
55+
rm -rf ${{ env.COMPONENT_LIBRARY_PATH }}
56+
if [ "${{ github.event_name }}" == "pull_request" ]; then
57+
REPO_URL="${{ github.event.pull_request.head.repo.clone_url }}"
58+
else
59+
REPO_URL="https://github.com/${{ github.repository }}"
60+
fi
61+
git clone -b ${{ env.BRANCH_NAME }} $REPO_URL ${{ env.COMPONENT_LIBRARY_PATH }}
62+
63+
- name: Install Component Library
64+
run: |
65+
if [ -f "${{ env.COMPONENT_LIBRARY_PATH }}/requirements.txt" ]; then
66+
echo "requirements.txt found, installing dependencies..."
67+
pip install -r ${{ env.COMPONENT_LIBRARY_PATH }}/requirements.txt
68+
else
69+
echo "requirements.txt not found."
70+
fi
71+
72+
- name: Test .xircuits Workflows
73+
run: |
74+
export PYTHONPATH="${GITHUB_WORKSPACE}:${PYTHONPATH}"
75+
LOG_FILE="${GITHUB_WORKSPACE}/workflow_logs.txt"
76+
TEST_FILES=$(echo "$TEST_XIRCUITS" | tr '\n' ' ')
77+
echo "Repository: $LIBRARY_NAME" > $LOG_FILE
78+
echo "Branch: $BRANCH_NAME" >> $LOG_FILE
79+
80+
GOOGLE_API_KEY="${{ secrets.API_KEY }}"
81+
82+
echo -e "Testing Files:\n$TEST_FILES" >> $LOG_FILE
83+
IFS=' ' read -r -a FILE_ARRAY <<< "$TEST_FILES"
84+
FAIL=0
85+
if [ ${#FILE_ARRAY[@]} -eq 0 ]; then
86+
echo "No .xircuits files specified for testing." | tee -a $LOG_FILE
87+
else
88+
for file in "${FILE_ARRAY[@]}"; do
89+
FULL_PATH="${COMPONENT_LIBRARY_PATH}/${file}"
90+
if [ -f "$FULL_PATH" ]; then
91+
WORKFLOW_LOG_FILE="${FULL_PATH%.*}_workflow_log.txt"
92+
echo -e "\n\nProcessing $FULL_PATH..." | tee -a $LOG_FILE
93+
xircuits compile $FULL_PATH "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE
94+
python "${FULL_PATH%.*}.py" --api_key "$GOOGLE_API_KEY" 2>&1 | tee -a $WORKFLOW_LOG_FILE
95+
96+
echo "Closing resources for $FULL_PATH..." | tee -a $WORKFLOW_LOG_FILE
97+
if grep -q "grpc" "$WORKFLOW_LOG_FILE"; then
98+
echo "Attempting to close gRPC channels..." | tee -a $WORKFLOW_LOG_FILE
99+
python -c "
100+
import grpc
101+
# Close gRPC channel
102+
try:
103+
channel = grpc.insecure_channel('localhost:50051')
104+
channel.close()
105+
print('gRPC channel closed successfully.')
106+
except Exception as e:
107+
print(f'Error closing gRPC channel: {e}')
108+
" | tee -a $WORKFLOW_LOG_FILE
109+
fi
110+
111+
if grep -q "Finished Executing" "$WORKFLOW_LOG_FILE"; then
112+
echo "$FULL_PATH processed successfully" | tee -a $LOG_FILE
113+
else
114+
echo "Error: Workflow $FULL_PATH did not finish as expected" | tee -a $LOG_FILE
115+
FAIL=1
116+
fi
117+
cat "$WORKFLOW_LOG_FILE" | tee -a $LOG_FILE
118+
else
119+
echo "Specified file $FULL_PATH does not exist" | tee -a $LOG_FILE
120+
FAIL=1
121+
fi
122+
done
123+
fi
124+
if [ $FAIL -ne 0 ]; then
125+
echo "One or more workflows failed or did not finish as expected." | tee -a $LOG_FILE
126+
exit 1
127+
else
128+
echo "Workflow processing completed successfully." | tee -a $LOG_FILE
129+
fi
130+
131+
132+
- name: Upload log file
133+
if: always()
134+
uses: actions/upload-artifact@v4
135+
with:
136+
name: ${{ env.LIBRARY_NAME }}-validation-workflow-${{ matrix.python-version }}
137+
path: ${{ github.workspace }}/workflow_logs.txt

0 commit comments

Comments
 (0)