Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger from another task #342

Open
dvett01 opened this issue Jan 4, 2024 · 3 comments
Open

Trigger from another task #342

dvett01 opened this issue Jan 4, 2024 · 3 comments

Comments

@dvett01
Copy link

dvett01 commented Jan 4, 2024

Hi, I am wondering if it is possible to trigger another plombery task (job2) from another plombery task(job1)?

I have a task that is running some code(job1), and sometimes it needs to renew the auth token(job2).
If it needs to renew, I tried to hit the api endpoint of job2, but it seems that jobs are blocking each other and plombery freezes.

Maybe someone can help me to get my head around it?

@CurtisFL
Copy link

Can i see a snippet of your code ?
The best solution i see here is to trigger the second task by making a post request to the pipeline endpoint

@mtroym
Copy link

mtroym commented Jul 18, 2024

by making a post request to the pipeline endpoint

Yes, currently plombery cannot dynamically edit/add/remove triggers by running jobs. the only way is to trigger by http api. but now the author did not post any http api documents.

I am also eager to this feature.

@D3m0n1cC09n1710n
Copy link

by making a post request to the pipeline endpoint

Yes, currently plombery cannot dynamically edit/add/remove triggers by running jobs. the only way is to trigger by http api. but now the author did not post any http api documents.

I am also eager to this feature.

Its fastapi it has docs inside of it by default no?

Anyways, cant we do:

def schedule_task(pipeline_id, params={}):
    resp = requests.post(f'http://{host}:{port}/api/runs/', json={'pipeline_id': pipeline_id, 'params': params})
    id = resp.json()['id']
    return id


def check_task_status(run_id):
    resp = requests.get(f'http://{host}:{port}/api/runs/{run_id}').json()
    if resp['status'] == 'completed':
        return 1
    elif resp['status'] == 'failed':
        return -1
    return 0


def get_task_data(run_id):
    resp = requests.get(f'http://{host}:{port}/api/runs/{run_id}').json()
    task_id = resp['tasks_run'][0]['task_id']
    data = requests.get(f'http://{host}:{port}/api/runs/{run_id}/data/{task_id}').json()
    return json.loads(data)

I used schedule_task inside a task for another task and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants