How to avoid looped Pentaho job logging "Finished job entry" rows multiple times? - pentaho-spoon

I have created looped Pentaho(v8.1) job, It circles in every 15 seconds and entire job works about 7 minutes, but after 5 or 6 minutes I get thousands of similar rows in log field with texts : "Finished job entry"
like this
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [Table input 3] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [Simple evaluation duration] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [SET PROCESS_STATUS 0] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [SEND CLIENTS&ACCOUNTS] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [FILL ALL ACCOUNTS] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [Wait for] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [SET PROCESS_STATUS 2] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [call procedure] (result=[true])
2019/03/28 11:47:49 - FILLALLACC_MAIN_WF - Finished job entry [SET PROCESS_STATUS 1] (result=[true])
...
How can I avoid logging this looped "Finished job entry" rows?

Try "Minimal" or "Error" log level when starting the job.
Otherwise, there's no way to suppress these messages. These are simply telling you what's going on in your job loops.

Related

Xcode does also include succeeded tests in failed test section

I am using Xcode's test plans with the option 'Retry until failure' and some repetitions. When a test fails but then succeeds, it will still show up in the failed test section when another test is actually consistently failing. This is my code:
import XCTest
class SomeTests: XCTestCase {
func testExampleA() throws {
let random = Int.random(in: 0...10)
// Will always fail
if random != -1 {
XCTFail("fail")
}
}
func testExampleB() throws {
let random = Int.random(in: 0...3)
if random != 1 {
XCTFail("fail")
}
}
}
And I run the test command:
xcodebuild test -project uitest.xcodeproj -scheme unittest -destination 'platform=iOS Simulator,name=iPhone 12,OS=15.5' -only-testing SomeTests
This is the output:
/Users/jaspervisser/Desktop/uitest/dfsdfsff/dfsdfsff.swift:16: error: -[dfsdfsff.SomeTests testExampleA] : failed - fail
Test Case '-[dfsdfsff.SomeTests testExampleA]' failed (0.005 seconds).
Test Case '-[dfsdfsff.SomeTests testExampleA]' started (Iteration 20 of 20).
/Users/jaspervisser/Desktop/uitest/dfsdfsff/dfsdfsff.swift:16: error: -[dfsdfsff.SomeTests testExampleA] : failed - fail
Test Case '-[dfsdfsff.SomeTests testExampleA]' failed (0.005 seconds).
Test Case '-[dfsdfsff.SomeTests testExampleB]' started (Iteration 1 of 20).
/Users/jaspervisser/Desktop/uitest/dfsdfsff/dfsdfsff.swift:24: error: -[dfsdfsff.SomeTests testExampleB] : failed - fail
Test Case '-[dfsdfsff.SomeTests testExampleB]' failed (0.005 seconds).
Test Case '-[dfsdfsff.SomeTests testExampleB]' started (Iteration 2 of 20).
/Users/jaspervisser/Desktop/uitest/dfsdfsff/dfsdfsff.swift:24: error: -[dfsdfsff.SomeTests testExampleB] : failed - fail
Test Case '-[dfsdfsff.SomeTests testExampleB]' failed (0.005 seconds).
Test Case '-[dfsdfsff.SomeTests testExampleB]' started (Iteration 3 of 20).
Test Case '-[dfsdfsff.SomeTests testExampleB]' passed (0.019 seconds).
Test Suite 'SomeTests' failed at 2022-07-04 17:55:03.367.
Executed 23 tests, with 22 failures (0 unexpected) in 0.184 (0.202) seconds
Test Suite 'dfsdfsff.xctest' failed at 2022-07-04 17:55:03.373.
Executed 23 tests, with 22 failures (0 unexpected) in 0.184 (0.209) seconds
Test Suite 'All tests' failed at 2022-07-04 17:55:03.377.
Executed 23 tests, with 22 failures (0 unexpected) in 0.184 (0.217) seconds
2022-07-04 17:55:28.752 xcodebuild[77552:4967879] [MT] IDETestOperationsObserverDebug: 31.789 elapsed -- Testing started completed.
2022-07-04 17:55:28.752 xcodebuild[77552:4967879] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2022-07-04 17:55:28.752 xcodebuild[77552:4967879] [MT] IDETestOperationsObserverDebug: 31.789 sec, +31.789 sec -- end
Test session results, code coverage, and logs:
/Users/jaspervisser/Library/Developer/Xcode/DerivedData/uitest-dthpivieuzigdfgvtdrzgailclme/Logs/Test/Test-unittest-2022.07.04_17-54-56-+0200.xcresult
Failing tests:
dfsdfsff:
SomeTests.testExampleA()
SomeTests.testExampleB()
** TEST FAILED **
You can see that testExampleB has succeeded, but it still pops up in the failing tests section. It takes me so much time in the 'real' CI to find actual consistently failing tests, I don't care about tests that fails and succeeds, I just need to kind consistently failing tests. Is there a way to identify them? Can I filter out tests that succeeds?

Airflow 2.0.2: Dag doesn't render correctly the template

I have two simple tasks, one is getting the list of ids, and the other has to shows the list of ids with echo command. The result in xcom push seems right . I have a list of tuple as below.
The output of return function(xcom push) is a list of tuple, as below:
[(19343160,), (19350561,), (19351381,), (19351978,), (19356674,), (19356676,), (19356678,), (19356681,), (19356682,), (19359607,)]
Here is my code:
def read_sql(file_name):
with open(SQL_PATH + file_name) as f:
sql = f.read()
return sql
def query_and_push(sql):
pg_hook = PostgresHook(postgres_conn_id='redshift')
records = pg_hook.get_records(sql=sql)
return records
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'email': ['airflow#example.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}
with DAG(
'xcom_using_jinja_template',
default_args=default_args,
description='',
schedule_interval=timedelta(days=1),
start_date=days_ago(2),
tags=['test'],
) as dag:
t1 = PythonOperator(
task_id='get_query_id',
python_callable=query_and_push,
provide_context=True,
op_kwargs={
'sql' : read_sql('warmupqueryid.sql')
}
)
templated_command = dedent(
"""
{% for item in params.query_ids %}
echo {{ item[0] }};
{% endfor %}
"""
)
t2 = BashOperator(
task_id='templated',
depends_on_past=False,
bash_command=templated_command,
params={'query_ids': " {{ ti.xcom_pull(task_ids='get_query_id'), key='return_value' }}"},
)
t1 >> t2
My last task is failing due to this error, and I don't understand why it's not getting the value of xcom push. I am not sure if this is a bug, or if I 've just missed something.
*** Reading remote log from s3://ob-airflow-pre/logs/xcom_using_jinja_template/templated/2021-05-26T17:22:44.023533+00:00/1.log.
[2021-05-26 17:22:45,633] {taskinstance.py:877} INFO - Dependencies all met for <TaskInstance: xcom_using_jinja_template.templated 2021-05-26T17:22:44.023533+00:00 [queued]>
[2021-05-26 17:22:45,663] {taskinstance.py:877} INFO - Dependencies all met for <TaskInstance: xcom_using_jinja_template.templated 2021-05-26T17:22:44.023533+00:00 [queued]>
[2021-05-26 17:22:45,663] {taskinstance.py:1068} INFO -
--------------------------------------------------------------------------------
[2021-05-26 17:22:45,663] {taskinstance.py:1069} INFO - Starting attempt 1 of 2
[2021-05-26 17:22:45,664] {taskinstance.py:1070} INFO -
--------------------------------------------------------------------------------
[2021-05-26 17:22:45,675] {taskinstance.py:1089} INFO - Executing <Task(BashOperator): templated> on 2021-05-26T17:22:44.023533+00:00
[2021-05-26 17:22:45,679] {standard_task_runner.py:52} INFO - Started process 413 to run task
[2021-05-26 17:22:45,683] {standard_task_runner.py:76} INFO - Running: ['airflow', 'tasks', 'run', 'xcom_using_jinja_template', 'templated', '2021-05-26T17:22:44.023533+00:00', '--job-id', '1811', '--pool', 'default_pool', '--raw', '--subdir', 'DAGS_FOLDER/xcom_test.py', '--cfg-path', '/tmp/tmpkk2x0gyd', '--error-file', '/tmp/tmpc2ka7x4x']
[2021-05-26 17:22:45,683] {standard_task_runner.py:77} INFO - Job 1811: Subtask templated
[2021-05-26 17:22:45,859] {logging_mixin.py:104} INFO - Running <TaskInstance: xcom_using_jinja_template.templated 2021-05-26T17:22:44.023533+00:00 [running]> on host airflow-worker-1.airflow-worker.airflow.svc.cluster.local
[2021-05-26 17:22:45,945] {taskinstance.py:1281} INFO - Exporting the following env vars:
AIRFLOW_CTX_DAG_EMAIL=airflow#example.com
AIRFLOW_CTX_DAG_OWNER=airflow
AIRFLOW_CTX_DAG_ID=xcom_using_jinja_template
AIRFLOW_CTX_TASK_ID=templated
AIRFLOW_CTX_EXECUTION_DATE=2021-05-26T17:22:44.023533+00:00
AIRFLOW_CTX_DAG_RUN_ID=manual__2021-05-26T17:22:44.023533+00:00
[2021-05-26 17:22:45,946] {bash.py:135} INFO - Tmp dir root location:
/tmp
[2021-05-26 17:22:45,947] {bash.py:158} INFO - Running command:
echo ;
echo {;
echo {;
echo ;
echo t;
echo i;
echo .;
echo x;
echo c;
echo o;
echo m;
echo _;
echo p;
echo u;
echo l;
echo l;
echo (;
echo t;
echo a;
echo s;
echo k;
echo _;
echo i;
echo d;
echo s;
echo =;
echo ';
echo g;
echo e;
echo t;
echo _;
echo q;
echo u;
echo e;
echo r;
echo y;
echo _;
echo i;
echo d;
echo ';
echo );
echo ,;
echo ;
echo k;
echo e;
echo y;
echo =;
echo ';
echo r;
echo e;
echo t;
echo u;
echo r;
echo n;
echo _;
echo v;
echo a;
echo l;
echo u;
echo e;
echo ';
echo ;
echo };
echo };
[2021-05-26 17:22:45,954] {bash.py:169} INFO - Output:
[2021-05-26 17:22:45,955] {bash.py:173} INFO -
[2021-05-26 17:22:45,955] {bash.py:173} INFO - {
[2021-05-26 17:22:45,955] {bash.py:173} INFO - {
[2021-05-26 17:22:45,955] {bash.py:173} INFO -
[2021-05-26 17:22:45,955] {bash.py:173} INFO - t
[2021-05-26 17:22:45,955] {bash.py:173} INFO - i
[2021-05-26 17:22:45,955] {bash.py:173} INFO - .
[2021-05-26 17:22:45,955] {bash.py:173} INFO - x
[2021-05-26 17:22:45,955] {bash.py:173} INFO - c
[2021-05-26 17:22:45,955] {bash.py:173} INFO - o
[2021-05-26 17:22:45,955] {bash.py:173} INFO - m
[2021-05-26 17:22:45,955] {bash.py:173} INFO - _
[2021-05-26 17:22:45,955] {bash.py:173} INFO - p
[2021-05-26 17:22:45,956] {bash.py:173} INFO - u
[2021-05-26 17:22:45,956] {bash.py:173} INFO - l
[2021-05-26 17:22:45,956] {bash.py:173} INFO - l
[2021-05-26 17:22:45,956] {bash.py:173} INFO - bash: -c: line 34: syntax error near unexpected token `;'
[2021-05-26 17:22:45,956] {bash.py:173} INFO - bash: -c: line 34: ` echo (;'
[2021-05-26 17:22:45,956] {bash.py:177} INFO - Command exited with return code 1
[2021-05-26 17:22:45,976] {taskinstance.py:1482} ERROR - Task failed with exception
Traceback (most recent call last):
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1138, in _run_raw_task
self._prepare_and_execute_task_with_callbacks(context, task)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1311, in _prepare_and_execute_task_with_callbacks
result = self._execute_task(context, task_copy)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/models/taskinstance.py", line 1341, in _execute_task
result = task_copy.execute(context=context)
File "/home/airflow/.local/lib/python3.8/site-packages/airflow/operators/bash.py", line 180, in execute
raise AirflowException('Bash command failed. The command returned a non-zero exit code.')
airflow.exceptions.AirflowException: Bash command failed. The command returned a non-zero exit code.
[2021-05-26 17:22:45,978] {taskinstance.py:1525} INFO - Marking task as UP_FOR_RETRY. dag_id=xcom_using_jinja_template, task_id=templated, execution_date=20210526T172244, start_date=20210526T172245, end_date=20210526T172245
[2021-05-26 17:22:46,014] {local_task_job.py:146} INFO - Task exited with return code 1
when I change params.query_ids to the list in above(harcoded) I am getting what I have excepted.
templated_command = dedent(
"""
{% for item in [(19343160,), (19350561,), (19351381,), (19351978,), (19356674,), (19356676,), (19356678,), (19356681,), (19356682,), (19359607,)] %}
echo {{ item[0] }};
{% endfor %}
"""
)
Expected result:
[2021-05-27 10:59:05,887] {bash.py:158} INFO - Running command:
echo 19343160;
echo 19350561;
echo 19351381;
echo 19351978;
echo 19356674;
echo 19356676;
echo 19356678;
echo 19356681;
echo 19356682;
echo 19359607;
I answered this on the Astronomer forum but providing the answer here as well for others - if helpful.
You won’t be able to use params in a Jinja-templated way directly with the bash_command as written since params is not a template_field for the BashOperator. However, you can reference the return_value XCom from the get_query_id task as a variable in Jinja like so:
templated_command = dedent(
"""
{% set query_ids = ti.xcom_pull(task_ids='get_query_id', key='return_value') %}
{% for item in query_ids %}
echo {{ item[0] }};
{% endfor %}
"""
)
t2 = BashOperator(
task_id='templated',
depends_on_past=False,
bash_command=templated_command,
)
Now the templated_command directly references the XCom you need and sets it to a variable in the Jinja string and get the output you expect:

regex to search multiple pattern

Edited my code, tried a different approach to get the desired output.
Let me know if it's correct
import re
pattern1 = re.compile(r'\b(ERROR)')
pattern2 = re.compile(r'^\d+-\d+-\d+')
count =0
with open('sample.txt',encoding='utf-8')as f:
for i in f:
a= re.search(pattern1,i)
if a:
count = count + 1
b = re.search(pattern2,i)
if b:
print(b.group(),':',a.group())
print('Total ERROR in the logfile:',count)
***output:***
2019-11-22 : ERROR
2019-11-22 : ERROR
2019-11-20 : ERROR
Total ERROR in the logfile: 3
log.txt
2019-11-22 16:46:46,985 - main - INFO - Starting to Wait for Files
2019-11-22 16:46:56,645 - main - INFO - Starting: Attempt 1 Checking for New Files
2019-11-22 16:47:46,488 - main - INFO - Success: Downloading the Files from Cloud Storage: Return
2019-11-22 16:48:48,180 - main - ERROR - Failed: Waiting for files the Files
2019-11-22 16:49:17,918 - main - INFO - Starting to Wait for Files
2019-11-22 16:49:32,160 - main - INFO - Starting: Attempt 1 Checking for New Files
2019-11-22 16:49:39,329 - main - WARNING - Success: Downloading the Files from Cloud Storage:
2019-11-22 16:53:30,706 - main - WARNING - Starting to Wait for Files
2019-11-22 16:53:48,180 - main - ERROR - Failed: Waiting for files the Files
2019-11-20 10:00:00,121 - main - ERROR - Failed: Waiting for files the Files
The pattern you should be using to match error lines is:
^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\bERROR\b.*$
Your updated script:
pattern1 = re.compile(r'^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.*\bERROR\b.*$')
count = 0
with open('log.txt',encoding='utf-8')as f:
for i in f:
a = re.search(pattern1, i)
if a:
count = count + 1

Oppo Realme1 Job Schduler Min interval for Periodic Work is 1 hr

Currently I am using WorkManager 1.0.0-alpha05. I set periodic Work Request using below code.
When interval is below 1 hr then In Oppo Realme (Android Version - 8.1.0 , ColorOSVersion V5.0)
job execute at 1 hr. When interval greater than 1 hr job execute at exact time . when interval is smaller than 1 hr then job execute at 1 hr.
Please let me know any log or information required :
Code For Schdule Periodic Job:
PeriodicWorkRequest uploadWork = new PeriodicWorkRequest.
Builder(LocationUpdatesJobService.class ,interval, TimeUnit.MILLISECONDS)
.addTag(Constants.Location.TAG_BACKGROUND_LOCATION_PERIODIC)
.setConstraints(constraints).build();
WorkManager.getInstance().enqueueUniquePeriodicWork(
Constants.Location.TAG_BACKGROUND_LOCATION_PERIODIC,
ExistingPeriodicWorkPolicy.REPLACE, uploadWork);
in all other device Periodic Work request interval is proper. In Oppo Realme 1 work execute at 1 hr.
Oppo Realme 1: Interval 15 Min
I debug Job Schduler using below command:
adb shell dumpsys jobscheduler
JOB #u0a249/18: cc2fc59 com.cygneto.field_sales/androidx.work.impl.background.systemjob.SystemJobService
u0a249 tag=job/com.cygneto.field_sales/androidx.work.impl.background.systemjob.SystemJobService
Source: uid=u0a249 user=0 pkg=com.cygneto.field_sales
JobInfo:
Service: com.cygneto.field_sales/androidx.work.impl.background.systemjob.SystemJobService
PERIODIC: interval=+1h0m0s0ms flex=+21m0s0ms
Requires: charging=false batteryNotLow=false deviceIdle=false
Extras: mParcelledData.dataSize=180
Backoff: policy=1 initial=+30s0ms
Has early constraint
Has late constraint
Required constraints: TIMING_DELAY DEADLINE
Satisfied constraints: APP_NOT_IDLE DEVICE_NOT_DOZING
Unsatisfied constraints: TIMING_DELAY DEADLINE
Doze whitelisted: true
Tracking: TIME
Enqueue time: -9m4s617ms
Run time: earliest=+29m55s383ms, latest=+50m55s383ms
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)
Oppo Realme 1: Interval 1hr 10 Min
Log:
JobInfo:
Service: com.cygneto.field_sales/androidx.work.impl.background.systemjob.SystemJobService
PERIODIC: interval=+1h10m0s0ms flex=+1h10m0s0ms
Requires: charging=false batteryNotLow=false deviceIdle=false
Extras: mParcelledData.dataSize=180
Doze whitelisted: true
Tracking: TIME
Enqueue time: -4m19s846ms
Run time: earliest=+1h5m39s833ms, latest=+2h15m39s833ms
Last successful run: 2018-07-25 17:01:23
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)
Other Device :
Log :
JobInfo:
Service:com.cygneto.field_sales/androidx.work.impl.background.systemjob.SystemJobService
PERIODIC: interval=+15m0s0ms flex=+15m0s0ms
Requires: charging=false batteryNotLow=false deviceIdle=false
Tracking: TIME
Enqueue time: -29s237ms
Run time: earliest=+14m30s690ms, latest=+29m30s690ms
Last successful run: 2018-07-25 17:29:19
Ready: false (job=false user=true !pending=true !active=true !backingup=true comp=true)
I also try Using different library. I found same behavior in Job Scheduler and Android-Job.
job period length is 15 min but execute at 1 hr but when i try using firebase job dispatcher
job execute at correct 15 min interval time.
i debug Job Scheduler and Android-Job using below command:
adb shell dumpsys jobscheduler
Job Scheduler:
Interval : 15 Min
Output : 1 hr
Log:
JOB #u0a266/1: a0dd846 com.jobscheduler_periodic/com.periodic.JobSchedulerService
u0a266 tag=*job*/com.jobscheduler_periodic/com.periodic.JobSchedulerService
Source: uid=u0a266 user=0 pkg=com.jobscheduler_periodic
JobInfo:
Service: com.jobscheduler_periodic/com.periodic.JobSchedulerService
PERIODIC: interval=+1h0m0s0ms flex=+15m0s0ms
Android-Job:
Interval : 15 Min
Output : 1 hr:
Log:
JOB #u0a266/3: 10c0d65 com.jobscheduler_periodic/com.evernote.android.job.v21.PlatformJobService
u0a266 tag=*job*/com.jobscheduler_periodic/com.evernote.android.job.v21.PlatformJobService
Source: uid=u0a266 user=0 pkg=com.jobscheduler_periodic
JobInfo:
Service: com.jobscheduler_periodic/com.evernote.android.job.v21.PlatformJobService
PERIODIC: interval=+1h0m0s0ms flex=+5m0s0ms
Firebase Job Dispatcher:
I debug firebase job Dispatcher using below command:
adb shell "dumpsys activity service GcmService | grep com.jobscheduler_periodic"
Interval : 15 Min
Output : 15 min
Log:
u0|com.jobscheduler_periodic: 1
(scheduled) com.jobscheduler_periodic/com.firebase.jobdispatcher.GooglePlayReceiver{u=0 tag="MyJobService" trigger=window{s
tart=720s,end=900s,earliest=46s,latest=226s} requirements=[NET_CONNECTED,CHARGING] attributes=[RECURRING] scheduled=-673s last_
run=N/A jid=N/A status=PENDING retries=0 client_lib=FIREBASE_JOB_DISPATCHER-1}
This happens to be an OEM bug. Unfortunately, it is very hard to work around these kind of bugs, in a battery efficient way. If you want a period of 15 mins, I suggest using the following workaround:
Use a OneTimeWorkRequest instead of a periodic work request, and upon first execution of the first work request, schedule a second from inside the worker with an initialDelay of 15 mins. That will essentially give you what you want.

Celery result disabled?

I am playing with demo cases with celery tutorial. However, the results were shown disabled when I start the task app. as below. Any idea?
celery --app=plmtcheck worker -l info
Then I see:
- ** ---------- .> app: plmtcheck:0x7f9fd2fdf160
- ** ---------- .> transport: amqp://guest#localhost:5672//
- ** ---------- .> results: disabled
I have seen the result is ready.
[2014-05-05 16:16:55,382: INFO/MainProcess] Connected to amqp://guest#127.0.0.1:5672//
[2014-05-05 16:16:55,389: INFO/MainProcess] mingle: searching for neighbors
[2014-05-05 16:16:56,401: INFO/MainProcess] mingle: all alone
[2014-05-05 16:16:56,422: WARNING/MainProcess] celery#D-NYC-00552088-Linux ready.
[2014-05-05 16:17:27,726: INFO/MainProcess] Received task: plmtcheck.add[7ea5a501-1085-48b7-8f7e-dac8ac2c5377]
[2014-05-05 16:17:27,759: INFO/MainProcess] Task plmtcheck.add[7ea5a501-1085-48b7-8f7e-dac8ac2c5377] succeeded in 0.032166894000056345s: 37
My code is simply
from celery import Celery
app = Celery('plmtcheck', backend='amqp', broker='amqp://')
#app.task
def add(x, y):
return x + y
if __name__ == '__main__':
app.worker_main()
install the django-celery-results package then add it in settings.py at
INSTALLED_APPS = [
...
'django_celery_results',
...
]
This will do what you intend to do