Skip to content

Commit

Permalink
Merge pull request #138 from jpuerto-psc/jpuerto/watching-param
Browse files Browse the repository at this point in the history
Jpuerto/watching param
  • Loading branch information
u8sand authored Mar 21, 2024
2 parents 985b72d + a0e46db commit 93d4961
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 47 deletions.
3 changes: 3 additions & 0 deletions appyter/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ def get_env_from_kwargs(**kwargs):
if 'hints' in kwargs or 'HINTS' not in _config:
_config['HINTS'] = try_json_loads(kwargs.get('hints', os.environ.get('APPYTER_HINTS', '')))
#
if 'watch' in kwargs or 'WATCH' not in _config:
_config['WATCH'] = False if not _config.get('DEBUG', False) else try_json_loads(kwargs.get('watch', True))
#
if _config['MODE'] == 'default' and (_config['IPYNB'] is None or not os.path.isfile(os.path.join(_config['CWD'], _config['IPYNB']))):
logger.error('ipynb was not found')
#
Expand Down
1 change: 1 addition & 0 deletions appyter/render/flask_app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ async def executor_ctx(app):
@click_option_setenv('--secret-key', envvar='APPYTER_SECRET_KEY', default=None, help='A secret key for flask')
@click_option_setenv('--debug', envvar='APPYTER_DEBUG', type=bool, default=True, help='Whether or not we should be in debugging mode, not for use in multi-tenant situations')
@click_option_setenv('--static-dir', envvar='APPYTER_STATIC_DIR', default='static', help='The folder whether staticfiles are located')
@click_option_setenv('--watch', envvar='APPYTER_WATCH', type=bool, default=True, help='Whether to watch files or not (when running in development)')
@click_argument_setenv('ipynb', envvar='APPYTER_IPYNB')
def flask_app(**kwargs):
import sys
Expand Down
95 changes: 48 additions & 47 deletions appyter/render/flask_app/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,53 +81,54 @@ async def serve(app_path, **kwargs):
# run the app and reload it when necessary
tasks.append(asyncio.create_task(app_runner(emitter, config)))
# the underlying appyter library
tasks.append(asyncio.create_task(
file_watcher(emitter, 'reload', appyter.__path__[0],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['*'],
include_file_glob=['*.py'],
exclude_dir_glob=[],
exclude_file_glob=[],
),
)
))
# the underlying appyter library's templates/ipynb/staticfiles/...
tasks.append(asyncio.create_task(
file_watcher(emitter, 'livereload', appyter.__path__[0],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['*'],
include_file_glob=['*'],
exclude_dir_glob=[],
exclude_file_glob=['*.py'],
),
)
))
# the appyter itself's filters/blueprints
tasks.append(asyncio.create_task(
file_watcher(emitter, 'reload', config['CWD'],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['filters', 'blueprints'],
include_file_glob=['*.py'],
exclude_dir_glob=[],
exclude_file_glob=[],
),
)
))
# the appyter itself's templates/ipynb/staticfiles/...
tasks.append(asyncio.create_task(
file_watcher(emitter, 'livereload', config['CWD'],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['*'],
include_file_glob=['*'],
exclude_dir_glob=[config['DATA_DIR']],
exclude_file_glob=['*.py'],
),
)
))
if config['WATCH']:
tasks.append(asyncio.create_task(
file_watcher(emitter, 'reload', appyter.__path__[0],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['*'],
include_file_glob=['*.py'],
exclude_dir_glob=[],
exclude_file_glob=[],
),
)
))
# the underlying appyter library's templates/ipynb/staticfiles/...
tasks.append(asyncio.create_task(
file_watcher(emitter, 'livereload', appyter.__path__[0],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['*'],
include_file_glob=['*'],
exclude_dir_glob=[],
exclude_file_glob=['*.py'],
),
)
))
# the appyter itself's filters/blueprints
tasks.append(asyncio.create_task(
file_watcher(emitter, 'reload', config['CWD'],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['filters', 'blueprints'],
include_file_glob=['*.py'],
exclude_dir_glob=[],
exclude_file_glob=[],
),
)
))
# the appyter itself's templates/ipynb/staticfiles/...
tasks.append(asyncio.create_task(
file_watcher(emitter, 'livereload', config['CWD'],
watcher_cls=GlobWatcher,
watcher_kwargs=dict(
include_dir_glob=['*'],
include_file_glob=['*'],
exclude_dir_glob=[config['DATA_DIR']],
exclude_file_glob=['*.py'],
),
)
))
tasks.append(asyncio.create_task(app_messager(emitter, config)))
exit_code = 0
try:
Expand Down

0 comments on commit 93d4961

Please sign in to comment.