我想在本地测试zappa_settings.json中的事件
我已经设置好了环境,并且我的本地机器上有一个运行Django站点的服务器,我还可以通过Zappa将Django站点部署到AWS。在将其推向云端之前,我想测试一下事件,该事件用于通过Lambda函数将cronjob部署到云端。我在导入时一直收到错误。
下面是我在zappa_settings.json中的事件
"events": [{
"function": "main.kpi_report.auto_scraper",
"expression": "cron(20 12 * * ? *)"
// "expression": "rate(10 minutes)"
}],下面是我的kpi_report.py文件中的导入
from .mws_settings import mws_settings
from .util import get_country_by_marketplace_name, date_amz_to_normal, process_currency
from .dynamodb import KPIPython3 manage.py运行服务器
System check identified no issues (0 silenced).
You have 14 unapplied migration(s). Your project may not work properly
until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
October 03, 2019 - 12:23:46
Django version 2.0.7, using settings 'com.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.最后,当我在本地机器上手动运行auto_scrapper时:
t$ python main/kpi_report.py auto_scrapper
Traceback (most recent call last):
File "main/kpi_report.py", line 14, in <module>
from .mws_settings import mws_settings
ModuleNotFoundError: No module named '__main__.mws_settings'; '__main__' is not a package
(zappa_env) t$ 我不确定如何在Zappa中测试cron作业(事件)。将代码上传到云中并等待事件运行并检查Lambda中的日志是非常低效的。请指教,TYIA
发布于 2020-07-16 01:18:32
您可以尝试只在本地执行main.kpi_report.auto_scraper
https://stackoverflow.com/questions/58219322
复制相似问题