Hello,
I’m new to temporal.
I have a workflow that require some global variable nlp_regression_param
.
This is how we do it in JAVA:
worker.addWorkflowImplementationFactory(NlpAnalyzeWorkflow.class, (Functions.Func<NlpAnalyzeWorkflow>) () -> new NlpAnalyzeWorkflowImpls(supportedLanguages.getValue()));
This is our implementation in Python:
@workflow.defn
class NlpWorkflow:
business_area = None
def __init__(self, nlp_regression_param: NlpRegression) -> None:
self.nlp_regression_param = nlp_regression_param
async def main():
run_futures = []
# Run the workers for the individual task queues
handle = Worker(
client,
task_queue=queue_id,
activities=[
nlp_regression_activity.activity_1,
nlp_regression_activity.run_activity_2,
],
workflows=[NlpWorkflow],
)
run_futures.append(handle.run())
if __name__ == "__main__":
loop = asyncio.new_event_loop()
try:
nlp_regression_activity = NlpRegressionActivity()
loop.run_until_complete(main())
except KeyboardInterrupt:
interrupt_event.set()
loop.run_until_complete(loop.shutdown_asyncgens())
logger.info("Shutting down workers")
We are getting this error: __init__() missing 1 required positional argument: 'nlp_regression_param'
Also, we tried this: workflows=[NlpWorkflow(nlp_regression_param)]
but we had this error: Workflow <unknown> missing attributes, was it decorated with @workflow.defn?