Skip to content

Commit 1da7c01

Browse files
authored
Initial commit
0 parents  commit 1da7c01

32 files changed

+1244
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
name: User story
3+
about: This template provides a basic structure for user story issues.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
# User story
11+
As a ..., I want to ..., so I can ...
12+
13+
*Ideally, this is in the issue title, but if not, you can put it here. If so, delete this section.*
14+
15+
# Acceptance criteria
16+
- [ ] This is something that can be verified to show that this user story is satisfied.
17+
18+
# Sprint Ready Checklist
19+
- [ ] 1. Acceptance criteria defined
20+
- [ ] 2. Team understands acceptance criteria
21+
- [ ] 3. Team has defined solution / steps to satisfy acceptance criteria
22+
- [ ] 4. Acceptance criteria is verifiable / testable
23+
- [ ] 5. External / 3rd Party dependencies identified
24+
- [ ] 6. Ticket is prioritized and sized
25+
26+
# Notes
27+
*Add any helpful notes here.*

.github/workflows/init.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Workflow runs only once when the template is first used.
2+
# File can be safely deleted after repo is initialized.
3+
name: Initialize repository
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
initialize-package:
11+
name: Initialize the package
12+
if: ${{github.event.repository.name != 'aind-service-template'}}
13+
runs-on: ubuntu-latest
14+
env:
15+
REPO_NAME: ${{ github.event.repository.name }}
16+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
- name: Rename package
21+
run: |
22+
pkg_name=$(echo "${REPO_NAME}" | tr - _)
23+
echo "Package Name ${pkg_name}"
24+
server_repo_name="${REPO_NAME}-server"
25+
server_pkg_name=$(echo "${server_repo_name}" | tr - _)
26+
mv aind-service-template-server/src/aind_service_template_server aind-service-template-server/src/${server_pkg_name}
27+
mv aind-service-template-server ${server_repo_name}
28+
echo "Server repo ${server_repo_name} directory"
29+
ls ${server_repo_name}
30+
echo "Server repo src directory"
31+
ls ${server_repo_name}/src
32+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/pyproject.toml
33+
sed -i "s/aind-service-template-server/${server_repo_name}/" ${server_repo_name}/pyproject.toml
34+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/Dockerfile
35+
sed -i "s/aind_service_template_server/${server_pkg_name}/" scripts/generate_openapi.py
36+
sed -i "s/aind-service-template-server/${server_repo_name}/" scripts/generate_openapi.py
37+
sed -i "s/aind-service-template-server/${server_repo_name}/" workflow_templates/test_server.yml
38+
sed -i "s/aind-service-template/${REPO_NAME}/" workflow_templates/tag_and_publish.yml
39+
sed -i "s/aind-service-template/${REPO_NAME}/" openapirc.json
40+
sed -i "s/aind_service_template/${pkg_name}/" openapirc.json
41+
sed -i "s/aind-service-template-server/${server_repo_name}/" ${server_repo_name}/src/${server_pkg_name}/main.py
42+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/src/${server_pkg_name}/main.py
43+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/src/${server_pkg_name}/handler.py
44+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/src/${server_pkg_name}/models.py
45+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/src/${server_pkg_name}/route.py
46+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/src/${server_pkg_name}/session.py
47+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/tests/conftest.py
48+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/tests/test_configs.py
49+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/tests/test_handler.py
50+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/tests/test_models.py
51+
sed -i "s/aind_service_template_server/${server_pkg_name}/" ${server_repo_name}/tests/test_session.py
52+
- name: Commit changes
53+
uses: EndBug/add-and-commit@v9
54+
with:
55+
default_author: github_actions
56+
message: "ci: initialize files [skip actions]"
57+
add: '["."]'
58+
- name: Add first tag
59+
run: |
60+
git tag v0.0.0
61+
git push origin v0.0.0
62+
- name: Disable workflow
63+
run: |
64+
gh workflow disable -R $GITHUB_REPOSITORY "${{ github.workflow }}"
65+
- name: Remove init file
66+
uses: EndBug/add-and-commit@v9
67+
with:
68+
default_author: github_actions
69+
message: "ci: remove init workflow [skip actions]"
70+
remove: '["-r .github/workflows/init.yml"]'

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
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+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
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+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
.idea/
169+
170+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Allen Institute for Neural Dynamics
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# aind-service-template
2+
A template repo that can be used for rapid development of FastAPI services.
3+
4+
## Usage
5+
6+
### Initialize a repo
7+
8+
- Click the green "Use This Template" button
9+
- Once the repo is created, please wait several seconds for the github action to initialize the files. You can check the status in the "Actions" tab.
10+
- Update the main README and *-server/README files if desired
11+
- It's recommended to update the repo settings to require Pull Requests and Reviews.
12+
13+
### Auto-run tests, publish docker image, and create client code
14+
15+
- In the repo settings, add `svc-aindscicomp` as an admin to the list of Collaborators.
16+
- Move the yaml files from `workflow_templates` to `.github/workflows/`
17+
- When a PR is opened, the server code will be tested.
18+
- When a PR is merged into main:
19+
- The tag will be incremented
20+
- The server code will be published as a docker image
21+
- The client code will be autogenerated from the openapi specification and published to PyPI
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude =
3+
.git,
4+
__pycache__,
5+
build,
6+
.venv,
7+
venv
8+
max-complexity = 10
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM python:3.10-slim
2+
WORKDIR /app
3+
4+
# Pip install
5+
ADD src ./src
6+
ADD pyproject.toml .
7+
ADD setup.py .
8+
9+
RUN pip install . --no-cache-dir
10+
11+
CMD ["fastapi", "run", "src/aind_service_template_server/main.py", "--port", "80"]

0 commit comments

Comments
 (0)