Commit 86d995e0 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

fix tool input, add watchdog

parent 35af5101
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ dataset_client.wait_for_dataset(uploaded_dataset_id)
# wc_gnu - id of the Galaxy's Line/Word/Character count tool
# so one needs to know tool id and tool inputs and outputs. This tool takes an input file and options for what to count
# and returns a single output file (hence ['outputs'][0]['id'])
tool_inputs = inputs().set("options", ["lines", "words"]).set("input", uploaded_dataset_id)
tool_inputs = inputs().set("options", ["lines", "words"]).set("input1", {"src": "hda", "id": uploaded_dataset_id})
result_dataset_id = galaxy_instance.tools.run_tool(history_id, 'wc_gnu', tool_inputs)['outputs'][0]['id']
dataset_client.wait_for_dataset(result_dataset_id)

+48 −0
Original line number Diff line number Diff line

import time
import requests
import json

from watchdog.observers.polling import PollingObserver as Observer

from watchdog.events import FileSystemEventHandler

url = "http://10.64.193.124:9001/v0.1/ingress"

def send_file(path):
    data = {
        "Path": path,
        "IptsNumber": "IPTS123",
        "RunNumber": 123
    }
    response = requests.post(url, json=data)
    if response.status_code == 200:
        print(f"Sent file {path} to NDIP")
    else:
        print(f"Could not send file {path} to NDIP, Status code:", response.status_code)
        print("Response:", response.text)

class Handler(FileSystemEventHandler):
    def on_created(self, event):
        if event.is_directory:
            return
        try:
            send_file(event.src_path)
        except Exception as e:
            print(e)


if __name__ == "__main__":
    path = "."
    event_handler = Handler()
    observer = Observer(timeout=1)
    observer.schedule(event_handler, path, recursive=False)
    observer.start()

    try:
        while True:
            time.sleep(1)
            pass
    except KeyboardInterrupt:
        observer.stop()
    observer.join()