Hey everyone, I'm currently learning my way around Prefect (and a lot of the other tools involved wi...
k

Ken Nguyen

about 4 years ago
Hey everyone, I'm currently learning my way around Prefect (and a lot of the other tools involved with Prefect) and tried to set up a simple hello task using GitHub storage. The task failed and resulted in this error in the log, could someone help me decipher it?
Failed to load and execute Flow's environment: GithubException(404, {'data': 'Not Found'}, {'server': '<http://GitHub.com|GitHub.com>', 'date': 'Thu, 26 Aug 2021 01:20:16 GMT', 'content-type': 'text/plain; charset=utf-8', 'transfer-encoding': 'chunked', 'vary': 'X-PJAX, X-PJAX-Container, Accept-Encoding, Accept, X-Requested-With', 'permissions-policy': 'interest-cohort=()', 'cache-control': 'no-cache', 'set-cookie': 'logged_in=no; domain=.<http://github.com|github.com>; path=/; expires=Fri, 26 Aug 2022 01:20:16 GMT; secure; HttpOnly; SameSite=Lax', 'strict-transport-security': 'max-age=31536000; includeSubdomains; preload', 'x-frame-options': 'deny', 'x-content-type-options': 'nosniff', 'x-xss-protection': '0', 'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin', 'expect-ct': 'max-age=2592000, report-uri="<https://api.github.com/_private/browser/errors>"', 'content-security-policy': "default-src 'none'; base-uri 'self'; connect-src 'self'; form-action 'self'; img-src 'self' data:; script-src 'self'; style-src 'unsafe-inline'", 'content-encoding': 'gzip', 'x-github-request-id': 'EA90:30AB:16BB88:2112BC:6126EC50'})
<@ULVA73B9P> I am using this code block. Why am I getting the warning "WARNING | EventsWorker - Stil...
k

Koen

8 months ago
@Marvin I am using this code block. Why am I getting the warning "WARNING | EventsWorker - Still processing items: 6 items remaining..."
from prefect import flow, get_run_logger, task, allow_failure
from prefect.states import Failed, Completed


#Custom Exception class that allows to return data
class TaskFailureException(Exception):
    def __init__(self, message, data):
        super().__init__(message)
        self.data = data


@task(task_run_name="task_that_raises: {x}")
def task_that_raises(x):    
    if x < 3:
        # Raise a custom exception with the data you want to preserve
        raise TaskFailureException(f"Value is too low: {x}", data=x)
    # Return data normally for a Completed state
    return x

@task()
def another_task(data):
    return (f"got here and showing data from previous task: {data}")
    

@flow()
def demo_passing_data():
    global run_logger
    run_logger = get_run_logger()

 
    task_run_future = task_that_raises.submit(x = 1) #task started


    try:
        result = task_run_future.result() #task fails, jump to except
        print(f"Task 2 completed with data: {result}")
        
    except TaskFailureException as e:
        print(f"Task failed with exception: {e}")
        # Access the data from the exception
        print(f"Failed task data: {e.data}")

        result = e.data
        task_run_future.wait()


    # Pass the result data to another_task and establish dependency
    future = another_task.submit(data=result)


    thistasksresult = future.result()
    print(thistasksresult)
    
    return Completed()

if __name__ == "__main__":
    demo_passing_data()