volkerjaenisch
11/22/2021, 11:17 PMKevin Kho
11/22/2021, 11:19 PMvolkerjaenisch
11/22/2021, 11:21 PMKevin Kho
11/22/2021, 11:22 PMvolkerjaenisch
11/22/2021, 11:24 PMKevin Kho
11/22/2021, 11:25 PMvolkerjaenisch
11/22/2021, 11:48 PMKevin Kho
11/22/2021, 11:50 PMvolkerjaenisch
11/22/2021, 11:51 PMfrom prefect import task
def to_func(cls):
"""Decorator to transform an operator class to a
function for an orion task decorator"""
instance = cls()
return instance.run
class BaseWorker:
def out(self, todo):
print(todo)
def run(self, todo):
self.out(todo)
return todo
@task(name='WorkerA')
@to_func
class WorkerA(BaseWorker):
def out(self, todo):
print('Worker A: ' + todo)
@task(name='WorkerB')
@to_func
class WorkerB(BaseWorker):
def out(self, todo):
print('Worker B: ' + todo)
class WorkerFactory:
def __call__(self, choice):
if choice == "A":
return WorkerA
elif choice == "B":
return WorkerB
@flow()
def main():
worker = WorkerFactory()('A')
<http://logger.info|logger.info>(worker('Examine Orion!'))
worker = WorkerFactory()('B')
<http://logger.info|logger.info>(worker('Examine Orion!'))
if __name__ == '__main__':
main()
Cheers,
Volker(orion-2cnkrIXd-py3.9) volker@runner:~/workspace/ORION/orion$ prefect orion start
Starting Orion API...
INFO: Started server process [471043]
18:03:22.344 | Started server process [471043]
INFO: Waiting for application startup.
18:03:22.344 | Waiting for application startup.
18:03:22.344 | Agent service scheduled to start in-app
18:03:22.344 | Scheduler service scheduled to start in-app
18:03:22.344 | MarkLateRuns service scheduled to start in-app
INFO: Application startup complete.
18:03:22.348 | Application startup complete.
INFO: Uvicorn running on <http://127.0.0.1:4200> (Press CTRL+C to quit)
18:03:22.349 | Uvicorn running on <http://127.0.0.1:4200> (Press CTRL+C to quit)
18:03:22.386 | Scheduled 0 runs.
18:03:22.387 | Finished monitoring for late runs.
18:03:27.370 | Finished monitoring for late runs.
INFO: 127.0.0.1:45934 - "OPTIONS /graphql HTTP/1.1" 200 OK
INFO: 127.0.0.1:45934 - "POST /graphql HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:45934 - "POST /graphql HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:45934 - "POST /graphql HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:45934 - "POST /graphql HTTP/1.1" 404 Not Found
18:03:32.370 | Finished monitoring for late runs.
INFO: 127.0.0.1:45934 - "POST /graphql HTTP/1.1" 404 Not Found
INFO: 127.0.0.1:45934 - "POST /graphql HTTP/1.1" 404 Not Found
Kevin Kho
11/22/2021, 11:53 PMvolkerjaenisch
11/22/2021, 11:53 PMKevin Kho
11/22/2021, 11:54 PMdev-Version
from GH, it looks like you are running Prefect Server on the same machine and it is occupying the portvolkerjaenisch
11/23/2021, 12:36 AMZanie
11/23/2021, 12:44 AMvolkerjaenisch
11/23/2021, 12:44 AMZanie
11/23/2021, 12:45 AMvolkerjaenisch
11/23/2021, 12:55 AMZanie
11/23/2021, 4:26 PMvolkerjaenisch
11/23/2021, 8:34 PM