Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cicd): update procfile + cli uses argparse only in local env #4

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ jobs:
matrix:
python-version: ["3.9", "3.10", "3.11"]

env:
SEQREPO_EB_PROD: true

steps:
- uses: actions/checkout@v4

Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
web: seqrepo-rest-service /usr/local/share/seqrepo/2024-02-20
web: cd src && gunicorn seqrepo_rest_service.cli:app --bind 0.0.0.0:5000
5 changes: 0 additions & 5 deletions cron.yaml

This file was deleted.

36 changes: 23 additions & 13 deletions src/seqrepo_rest_service/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,30 @@ def _parse_opts():
return opts


cxapp = connexion.App(__name__, debug=True)


def main():
coloredlogs.install(level="INFO")

if "SEQREPO_DIR" in os.environ:
_logger.warn("SEQREPO_DIR environment variable is now ignored")
if "SEQREPO_EB_PROD" in os.environ:
# AWS Elastic Beanstalk env
seqrepo_dir = os.environ.get("SEQREPO_ROOT_DIR", "/usr/local/share/seqrepo/2024-02-20")
else:
# Local env
if "SEQREPO_ROOT_DIR" in os.environ:
_logger.warn("SEQREPO_ROOT_DIR environment variable is now ignored")

opts = _parse_opts()
opts = _parse_opts()

seqrepo_dir = opts.SEQREPO_INSTANCE_DIR
if opts.wait_for_path:
while not seqrepo_dir.exists():
_logger.info(f"{seqrepo_dir}: waiting for existence")
time.sleep(WAIT_POLL_PERIOD)
_logger.info(f"{seqrepo_dir}: path found")
_ = SeqRepo(seqrepo_dir.as_posix()) # test opening
seqrepo_dir = opts.SEQREPO_INSTANCE_DIR
if opts.wait_for_path:
while not seqrepo_dir.exists():
_logger.info(f"{seqrepo_dir}: waiting for existence")
time.sleep(WAIT_POLL_PERIOD)
_logger.info(f"{seqrepo_dir}: path found")
_ = SeqRepo(seqrepo_dir.as_posix()) # test opening

cxapp = connexion.App(__name__, debug=True)
cxapp.app.url_map.strict_slashes = False
cxapp.app.config["seqrepo_dir"] = seqrepo_dir

Expand All @@ -79,8 +86,11 @@ def refget_ui():
return redirect("/refget/1/ui/")

_logger.info("Also watching " + str(spec_files))
cxapp.run(host="0.0.0.0", extra_files=spec_files)

return cxapp.app, spec_files


app, spec_files = main()

if __name__ == "__main__":
main()
app.run(host="0.0.0.0", extra_files=spec_files)
Loading