我正在使用 Celery 和 Redis 运行 Airflow,它运行良好,但我在工作人员方面遇到了问题。我有两个 docker-compose 文件,一个是在服务器中运行的 master 和一个在其他 pc 中运行的 worker。
我有 dag 运行python script.py但总是失败,因为它找不到脚本。似乎 Airflow Base 任务运行器只是将 dag 文件复制到 tmp 文件夹。
Run Code Online (Sandbox Code Playgroud)my dags folder is like: dags/ test_dag.py test.py
test_dag.py
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from datetime import datetime, timedelta
default_args = {
'owner': 'airflow',
'start_date': datetime(2018, 9, 3)
}
dag = DAG('test', default_args=default_args, schedule_interval='*/20 * * * *', catchup=False)
curl = BashOperator(
task_id='testingbash',
bash_command="python test.py",
dag=dag)
Run Code Online (Sandbox Code Playgroud)
测试文件
print('it worked')
Run Code Online (Sandbox Code Playgroud)
错误:
[2018-09-06 …Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个使用 API 作为大学项目后端的 Web 应用程序。
我已经读过 DRF 是开发和部署 API 的最快和最简单的方法,我已经遵循了他们的整个官方
文档,我似乎不明白我如何在他们的 ViewSet 和 Serializer 中进行以下操作。
这是我的 API 的一个端点,称为机场。
返回指向美国可用机场的链接的 json/csv 列表。
网址
/airports
方法:
GET
成功响应:
[
{
"airport": {
"code": "PHL",
"name": "Philadelphia, PA: Philadelphia International",
"id": 123,
"url": "/airports/123"
},
{
"airport": {
"code": "AHR",
"name": "American Hour Rapid",
"id": 125,
"url": "/airports/125"
}
.
.
.
]
Run Code Online (Sandbox Code Playgroud)返回指向在特定机场运营的航空公司的所有链接、指向特定月份和年份的相关统计数据的链接以及指向机场航线的链接。如果既未指定年份也未指定月份,则默认为具有最近日期的日期。
/airports/:id
GET
网址参数
必需的:
id=[integer]
成功响应:
{
"airport": {
"code": …Run Code Online (Sandbox Code Playgroud) django api-design django-views python-3.x django-rest-framework
我正在尝试使用 Axios 向我的 API(Django REST 框架)发出请求,但出现以下错误:
Access to XMLHttpRequest at 'http://trvl.hopto.org:8000/api/airports/MSP/routes' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Run Code Online (Sandbox Code Playgroud)
当你使用 cUrl 来检查时,甚至很难:
curl -I -X GET -H "Origin: http://localhost:3000" -H 'Access-Control-Request-Method: GET' http://trvl.hopto.org:8000/api/airports/MSP/routes 2>&1 | grep 'Access-Control-Allow-Origin'
Response: Access-Control-Allow-Origin: *
Full response from cUrl Options:
OPTIONS request: curl -I -X OPTIONS -H "Origin: http://localhost:3000" -H 'Access-Control-Request-Method: GET' http://trvl.hopto.org:8000/api/airports/MSP/routes
HTTP/1.1 200 OK
Date: Wed, 27 Mar 2019 10:58:01 GMT
Server: WSGIServer/0.2 …Run Code Online (Sandbox Code Playgroud) javascript django-rest-framework reactjs django-cors-headers axios
airflow ×1
api-design ×1
axios ×1
bash ×1
django ×1
django-views ×1
javascript ×1
python ×1
python-3.x ×1
reactjs ×1