-
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 #23 from usegalaxy-au/local-render
Local render Lab pages
- Loading branch information
Showing
6 changed files
with
132 additions
and
24 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
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,46 @@ | ||
"""Command line interface for launching a development server. | ||
This is intended to be used for rendering Lab pages in development. | ||
""" | ||
|
||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
|
||
def main(): | ||
"""CLI entry point for running the development server.""" | ||
try: | ||
from django.core.management import execute_from_command_line | ||
except ImportError as exc: | ||
raise ImportError( | ||
"Couldn't import Django. Make sure it's installed and " | ||
"available on your PYTHONPATH environment variable." | ||
) from exc | ||
|
||
os.environ["DJANGO_SETTINGS_MODULE"] = "app.settings.cli" | ||
set_required_env_vars() | ||
|
||
if sys.argv[1] == "serve": | ||
BASE_DIR = Path(__file__).resolve().parent.parent | ||
os.chdir(BASE_DIR) | ||
sys.path.insert(0, str(BASE_DIR)) | ||
if len(sys.argv) > 2: | ||
os.environ["LAB_CONTENT_ENTRYPOINT"] = sys.argv[2] | ||
execute_from_command_line(["manage.py", "runserver"]) | ||
else: | ||
print(f"Unknown command: {sys.argv[1]}") | ||
|
||
|
||
def set_required_env_vars(): | ||
"""Set required environment variables for the CLI.""" | ||
os.environ.setdefault("LAB_CONTENT_ROOT", os.getcwd()) | ||
os.environ.setdefault("HOSTNAME", "localhost:8000") | ||
os.environ.setdefault("MAIL_HOSTNAME", "localhost") | ||
os.environ.setdefault("MAIL_SMTP_PORT", "22") | ||
os.environ.setdefault("MAIL_FROM_ADDRESS", "[email protected]") | ||
os.environ.setdefault("MAIL_TO_ADDRESS", "[email protected]") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 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,32 @@ | ||
"""Local Lab development settings. | ||
To be used when pip-installed and running as `labs-engine serve`. | ||
""" | ||
|
||
# flake8: noqa | ||
|
||
import os | ||
|
||
from .base import * | ||
|
||
DEBUG = True | ||
CLI_DEV = True | ||
LAB_CONTENT_ROOT = os.environ.get('LAB_CONTENT_ROOT') | ||
if not LAB_CONTENT_ROOT: | ||
raise EnvironmentError('Env variable LAB_CONTENT_ROOT not set') | ||
LAB_CONTENT_ENTRYPOINT = os.environ.get('LAB_CONTENT_ENTRYPOINT', 'base.yml') | ||
|
||
INTERNAL_IPS = [ | ||
"127.0.0.1", | ||
] | ||
|
||
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend" | ||
|
||
STATICFILES_DIRS = [ | ||
("local", LAB_CONTENT_ROOT), | ||
] | ||
|
||
DEFAULT_EXPORTED_LAB_CONTENT_ROOT = ( | ||
f"http://{HOSTNAME}/static/local/{LAB_CONTENT_ENTRYPOINT}") | ||
|
||
INSTALLED_APPS.remove('django_light') |
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 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,25 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name="galaxy-labs-engine", | ||
version="1.0.0", | ||
packages=find_packages(where='app'), | ||
package_dir={'': 'app'}, | ||
include_package_data=True, | ||
install_requires=[ | ||
"django>=4.0", # Add any dependencies here | ||
"django>=5.0", | ||
"pyyaml>=6.0", | ||
"pydantic>=2.0", | ||
"markdown2>=2.0", | ||
"beautifulsoup4>=4.0", | ||
"requests>=2.0", | ||
"django-crispy-forms>=2.0", | ||
"crispy-bootstrap5>=2024.0", | ||
], | ||
entry_points={ | ||
"console_scripts": [ | ||
"labs-engine=app.cli:main", | ||
], | ||
}, | ||
) |