-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Small-Bodies-Node/infrastructure-update-20…
…24.02 Infrastructure update 2024.02
- Loading branch information
Showing
20 changed files
with
671 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Copyright 2021-2024 SBN Survey Image Service Developers | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,88 @@ | ||
#!/usr/bin/env false | ||
#!/bin/bash | ||
|
||
### 0. Load vars defined in .env | ||
if [ ! -f $PWD/.env ]; then | ||
echo -e "No .env file found. Generate with '_sbnsis env' then edit." | ||
return 1 | ||
set -e | ||
|
||
reset_color="\033[00m" | ||
black="\033[30m" | ||
red="\033[31m" | ||
green="\033[32m" | ||
yellow="\033[33m" | ||
blue="\033[34m" | ||
magenta="\033[35m" | ||
cyan="\033[36m" | ||
white="\033[37m" | ||
|
||
if [[ -z $PYTHON ]]; then | ||
PYTHON=python3 | ||
fi | ||
source .env | ||
|
||
### 1. Message user | ||
clear | ||
echo -e """${GRE} | ||
======================================= | ||
Initializing Python Virtual Environment | ||
======================================= | ||
${WHI}""" | ||
echo -e """${green} | ||
========================== | ||
Python Virtual Environment | ||
========================== | ||
${reset_color}""" | ||
|
||
sleep 1 | ||
|
||
### 2. Get rid of caches NOT in .venv | ||
### Get rid of caches NOT in .venv | ||
echo -e """${cyan} | ||
Cleaning cached pyc files | ||
${reset_color}""" | ||
find . -type d ! -path './.venv/*' -name '__pycache__' -exec rm -rf {} + | ||
find . -type d ! -path './.venv/*' -name '.pytest_cache' -exec rm -rf {} + | ||
find . -type d ! -path './.venv/*' -name '.mypy_cache' -exec rm -rf {} + | ||
|
||
### 3. Check for existence of `.venv` dir | ||
### Check for existence of `.venv` dir | ||
if [[ ! -d $PWD/.venv ]]; then | ||
echo -e """${BLU} | ||
virtual Environment Not Found -- Creating '.venv' | ||
""" | ||
$PYTHON_3_6_OR_HIGHER -m venv .venv --prompt=$APP_NAME | ||
echo -e """${cyan} | ||
Virtual environment not found -- Creating ".venv" | ||
${reset_color}""" | ||
$PYTHON -m venv .venv --prompt=sbn-survey-image-service | ||
else | ||
echo -e """${cyan} | ||
Virtual environment found in ".venv" | ||
${reset_color}""" | ||
fi | ||
|
||
### 4. Activate VENV | ||
### Activate VENV | ||
source ./.venv/bin/activate | ||
|
||
### 5. Install package dependencies for project | ||
### Install package dependencies for project | ||
|
||
echo -e """${green} | ||
=========================== | ||
Setup dependencies and code | ||
=========================== | ||
${reset_color}""" | ||
|
||
pip install --upgrade -q -q -q pip setuptools wheel | ||
pip install -q -r requirements.vscode.txt | ||
pip install -q -r requirements.txt | ||
pip install -e . | ||
pip install -e .[recommended,dev] | ||
|
||
if [[ ! -e $VIRTUAL_ENV/bin/fitscut ]]; then | ||
echo -e """${BLU} | ||
installing fitscut | ||
${WHI} | ||
echo -e """${cyan} | ||
Installing fitscut | ||
${reset_color} | ||
""" | ||
./_install_fitscut | ||
fi | ||
|
||
### 6. Link git pre-commit-hook script | ||
### Link git pre-commit-hook script | ||
ln -fs $PWD/_precommit_hook $PWD/.git/hooks/pre-commit | ||
|
||
if [ ! -f $PWD/.env ]; then | ||
echo -e """${red} | ||
To create a .env file: | ||
source .venv/bin/activate | ||
_sbnsis env | ||
Then edit .env | ||
${reset_color}""" | ||
fi | ||
|
||
### 7. Final Message | ||
echo -e """${BLU} | ||
echo -e """${cyan} | ||
Done. Bon courage! | ||
${WHI} | ||
""" | ||
${reset_color} | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#!/bin/bash | ||
./.venv/bin/python3 -m sbn_survey_image_service.scripts.sbnsis $* | ||
#!/usr/bin/env python3 | ||
from sbn_survey_image_service.scripts.sbnsis import SBNSISService | ||
SBNSISService() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
[project] | ||
name = "sbn-survey-image-service" | ||
description = "Serves images and cutouts via REST API." | ||
readme = "readme.md" | ||
authors = [ | ||
{ name = "Michael S. P. Kelley", email = "[email protected]" } | ||
] | ||
license = { text = "BSD 3-Clause License" } | ||
dependencies = [ | ||
"Flask>=3.0", | ||
"Flask-Cors>=4.0", | ||
"gunicorn>=21", | ||
"connexion>=3.0", | ||
"swagger-ui-bundle>1.0", | ||
"astropy>=6.0", | ||
"pds4_tools==1.3", | ||
"SQLAlchemy>=2.0", | ||
"python-dotenv>1.0", | ||
"pytest-remotedata>=0.4", | ||
] | ||
dynamic = ["version"] | ||
|
||
[project.urls] | ||
homepage = "https://github.com/Small-Bodies-Node/sbn-survey-image-service" | ||
|
||
[build-system] | ||
requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] | ||
build-backend = 'setuptools.build_meta' | ||
|
||
[tool.setuptools_scm] | ||
|
||
[tool.setuptools] | ||
zip-safe = false | ||
|
||
[tool.setuptools.packages.find] | ||
|
||
[project.optional-dependencies] | ||
recommended = [ | ||
"psycopg2-binary>=2.8", | ||
] | ||
dev = [ | ||
"autopep8", | ||
"mypy", | ||
"pycodestyle", | ||
"pytest>=7.0", | ||
"pytest-cov>=3.0", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
"""SBN Survey Image Service""" | ||
|
||
import os | ||
from importlib.metadata import version as _version, PackageNotFoundError | ||
|
||
# make cache directory set umask | ||
from . import exceptions | ||
from . import env | ||
from . import services | ||
from . import models | ||
import os | ||
os.system(f'mkdir -p {env.ENV.SBNSIS_CUTOUT_CACHE}') | ||
del os | ||
|
||
try: | ||
__version__ = _version(__name__) | ||
except PackageNotFoundError: | ||
pass | ||
|
||
os.system(f"mkdir -p {env.ENV.SBNSIS_CUTOUT_CACHE}") | ||
del os, PackageNotFoundError, _version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.