Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
MFA-X-AI authored Jan 25, 2024
0 parents commit 6aee180
Show file tree
Hide file tree
Showing 12 changed files with 916 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Bug Report
about: Share your findings to help us squash those bugs
title: ''
labels: ''
assignees: ''

---

**What kind of bug is it?**
- [ ] Xircuits Component Library Code
- [ ] Workflow Example
- [ ] Documentation
- [ ] Not Sure

**Xircuits Version**
Run `pip show xircuits` to get the version, or mention you've used a specific .whl from a branch.

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Tested on?**

- [ ] Windows
- [ ] Linux Ubuntu
- [ ] Centos
- [ ] Mac
- [ ] Others (State here -> xxx )

**Additional context**
Add any other context about the problem here.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Feature Request
about: Suggest an idea for this component library
title: ''
labels: ''
assignees: ''

---

**Xircuits Version**
Run `pip show xircuits` to get the version, or mention you've used a specific .whl from a branch.

**What kind of feature is it?**
- [ ] Xircuits Component Library Code
- [ ] Workflow Example
- [ ] Documentation
- [ ] Not Sure

**Is your feature request related to a problem? Please describe.**

A clear and concise description of what the problem is. Ex. When I use X feature / when I do Y it does Z.

**Describe the solution you'd like**

A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
46 changes: 46 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Welcome to Xircuits! Thank you for making a pull request. Please ensure that your pull request follows the template.

# Description

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.

## References

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.

## Pull Request Type

- [ ] Xircuits Component Library Code
- [ ] Workflow Example
- [ ] Documentation
- [ ] Others (Please Specify)

## Type of Change

- [ ] New feature (non-breaking change which adds functionality)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

# Tests

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.

**1. Test A**

1. First step
2. Second step
3. ...


## Tested on?

- [ ] Windows
- [ ] Linux Ubuntu
- [ ] Centos
- [ ] Mac
- [ ] Others (State here -> xxx )

# Notes

Add if any.
96 changes: 96 additions & 0 deletions .github/workflows/run-workflow-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Run Xircuits Workflows Test

on:
push:
branches: [ main ]
pull_request:
branches: "*"

jobs:
build-and-run:
runs-on: ubuntu-latest
env:
TEST_XIRCUITS: |
examples/example.xircuits
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Install xircuits
run: pip install xircuits

- name: Set Environment Variables
run: |
LIBRARY_NAME=$(echo "${GITHUB_REPOSITORY##*/}" | sed 's/-/_/g')
echo "LIBRARY_NAME=$LIBRARY_NAME" >> $GITHUB_ENV
COMPONENT_LIBRARY_PATH="xai_components/${LIBRARY_NAME}"
echo "COMPONENT_LIBRARY_PATH=$COMPONENT_LIBRARY_PATH" >> $GITHUB_ENV
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
fi
- name: List Xircuits
run: xircuits list

- name: Clone Repository
run: git clone -b ${{ env.BRANCH_NAME }} https://github.com/${{ github.repository }} ${{ env.COMPONENT_LIBRARY_PATH }}

- name: Install Component Library
run: |
if [ -f "${{ env.COMPONENT_LIBRARY_PATH }}/requirements.txt" ]; then
echo "requirements.txt found, installing dependencies..."
pip install -r ${{ env.COMPONENT_LIBRARY_PATH }}/requirements.txt
else
echo "requirements.txt not found."
fi
- name: Test .xircuits Workflows
run: |
export PYTHONPATH="${GITHUB_WORKSPACE}:${PYTHONPATH}"
LOG_FILE="${GITHUB_WORKSPACE}/workflow_logs.txt"
TEST_FILES=$(echo "$TEST_XIRCUITS" | tr '\n' ' ')
echo "Repository: $LIBRARY_NAME" > $LOG_FILE
echo "Branch: $BRANCH_NAME" >> $LOG_FILE
echo -e "Testing Files:\n$TEST_FILES" >> $LOG_FILE
IFS=' ' read -r -a FILE_ARRAY <<< "$TEST_FILES"
FAIL=0
if [ ${#FILE_ARRAY[@]} -eq 0 ]; then
echo "No .xircuits files specified for testing." | tee -a $LOG_FILE
else
for file in "${FILE_ARRAY[@]}"; do
FULL_PATH="${COMPONENT_LIBRARY_PATH}/${file}"
if [ -f "$FULL_PATH" ]; then
WORKFLOW_LOG_FILE="${FULL_PATH%.*}_workflow_log.txt"
echo -e "\n\nProcessing $FULL_PATH..." | tee -a $LOG_FILE
xircuits compile $FULL_PATH "${FULL_PATH%.*}.py" 2>&1 | tee -a $LOG_FILE
python "${FULL_PATH%.*}.py" 2>&1 | tee -a $WORKFLOW_LOG_FILE
LAST_LINE=$(tail -n 1 "$WORKFLOW_LOG_FILE")
if [[ "$LAST_LINE" != "Finished Executing" ]]; then
echo "Error: Workflow $FULL_PATH did not finish as expected" | tee -a $LOG_FILE
FAIL=1
else
echo "$FULL_PATH processed successfully" | tee -a $LOG_FILE
fi
cat "$WORKFLOW_LOG_FILE" | tee -a $LOG_FILE
else
echo "Specified file $FULL_PATH does not exist" | tee -a $LOG_FILE
FAIL=1
fi
done
fi
if [ $FAIL -ne 0 ]; then
echo "One or more workflows failed or did not finish as expected." | tee -a $LOG_FILE
exit 1
else
echo "Workflow processing completed" | tee -a $LOG_FILE
fi
- name: Upload log file
if: always()
uses: actions/upload-artifact@v3
with:
name: ${{ env.LIBRARY_NAME }}-validation-workflow
path: ${{ github.workspace }}/workflow_logs.txt
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
Loading

0 comments on commit 6aee180

Please sign in to comment.