我真的是这个论坛的新手.但是我一直在为我们的公司玩气流.对不起,这个问题听起来真的很蠢.
我正在使用一堆BashOperator编写一个管道.基本上,对于每个任务,我想简单地使用'curl'调用REST api
这是我的管道看起来像(非常简化的版本):
from airflow import DAG
from airflow.operators import BashOperator, PythonOperator
from dateutil import tz
import datetime
datetime_obj = datetime.datetime
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'start_date': datetime.datetime.combine(datetime_obj.today() - datetime.timedelta(1), datetime_obj.min.time()),
'email': ['xxxx@xxx.xxx'],
'email_on_failure': True,
'email_on_retry': False,
'retries': 2,
'retry_delay': datetime.timedelta(minutes=5),
}
current_datetime = datetime_obj.now(tz=tz.tzlocal())
dag = DAG(
'test_run', default_args=default_args, schedule_interval=datetime.timedelta(minutes=60))
curl_cmd='curl -XPOST "'+hostname+':8000/run?st='+current_datetime +'"'
t1 = BashOperator(
task_id='rest-api-1',
bash_command=curl_cmd,
dag=dag)
Run Code Online (Sandbox Code Playgroud)
如果你注意到我在做什么current_datetime= datetime_obj.now(tz=tz.tzlocal())
而不是我想要的是'execution_date'
如何直接使用'execution_date'并将其分配给我的python文件中的变量?
我有这个访问args的一般问题.任何帮助将得到真诚的感谢.
谢谢
我正在尝试查询数据(使用solr)并获得一天的粒度计数.
我遇到以下代码问题:
solrQuery.addDateRangeFacet("startTimeISO", date1.toDate(), date2.toDate(), "%2B1DAY");
solrQuery.setQuery(queryString);
QueryResponse response = null;
try {
response = solrClient.getSolrServer(getCollectionName(Constants.WebPeerAnomaliesModelTuple()._1())).query(solrQuery);
} catch (Exception exp) {
LOGGER.error("Failed to get facet results: ", exp);
}
Run Code Online (Sandbox Code Playgroud)
我在这里得到的错误是:
"不能将差距%2B1DAY添加到价值2014年11月14日06:37:30太平洋标准时间2014年字段:startTimeISO"
有人可以帮我解决这个问题吗?
我不确定为什么"%2B1DAY"会失败.当我从浏览器中执行相同操作时,我得到了正确的结果.如果我从url查询下面的内容,它可以工作:/select?facet = true&facet.date = startTimeISO&facet.date.start = NOW/DAY-30DAYS&facet.date.end = NOW/DAY%2B1DAY&facet.date.gap =%2B1DAY
如果我问一个微不足道的问题,请道歉.我还在尝试调试这个.任何指针都会有所帮助.谢谢.
更新:解决方案:
我能够调试这个并找出我收到此错误的原因.
在我的Java代码中,我应该添加"+ 1Day"而不是"%2B1DAY".通过浏览器查询工作因为+是%2B(网址编码)抱歉这个愚蠢的问题.希望它可以帮助某人.:)
我对 Airflow 很陌生,并试图了解我们应该如何在我们的环境中(在 aws 上)设置它。
我读了 Airflow 使用 Celery 和 redis 代理。它与 Mesos 有何不同?我之前没有使用过 Celery,但我尝试在我的开发机器上设置 celery-redis 并且它很容易工作。但是添加新组件意味着添加更多监控。
由于我们已经使用 mesos 进行集群管理,我想如果我不选择 celery 而是使用 MesosExecutor,我会错过什么?
我这里的第一个问题.请原谅,我刚刚进入C++并开始使用DS.堆!!!
我的代码:我想
using namespace std;
typedef char stackElement;
class Stack
{
public:
stackElement *contents; //dynamically allocated: as we do not know what would be the size of our array.
int top, maxSize; // current Top index in the array
//max size of the array; we need it to know if the array is full
Stack(int maxSize)
{
contents = new stackElement(maxSize);
this.maxSize = maxSize;
if(contents == NULL)
{
cout<<"Insufficient memory";
exit(1);
}
top = -1;
}
~Stack()
{
delete [] …Run Code Online (Sandbox Code Playgroud) //编辑:跟进问题:
但是将函数设为as isUnique(const char *s)
然后调用函数isUnique(str.c_str()) 不允许我str在函数中修改我的字符串
//
我遇到传递字符串的问题:
bool isUnique(char *s)
{
int arr[256] = {0};
while(*s)
{
arr[*s]++;
if(arr[*s]>1)
{
cout<<"not unique";
return false;
}
}
}
int main()
{
string str = "abcda";
cout<<"1: True : unique, 2: False: Not Unique"<<endl<<isUnique(str);
}
Run Code Online (Sandbox Code Playgroud)
错误:无法将参数'1'的'std :: string {aka std :: basic_string}'转换为'char*'为'bool isUnique(char*)'
我知道我可以做到这一点str.c_str(),但我不希望角色不变.我想要一个char,以便我可以做一些修改.
char* removeDup(char *s)
{
int len = strlen(s);
int p,q, idx = -1;
for(p = 0; p< len; p++)
{
char temp = s[p];
bool flag = true;
for(q=0;q<p;q++)
{
if(s[q] == temp)
{
flag = false;
break;
}
}
if(flag == true)
{
s[++idx] = temp;
}
}
s[++idx] = '\0';
return s;
}
Run Code Online (Sandbox Code Playgroud)
如果我将此函数调用如下,我会收到错误;
string s = "abcde";
removeDuplicate(s.c_str());
Run Code Online (Sandbox Code Playgroud)
我需要将其转换s为char而不是const char.