Normalised the processor's by making the common arguments positional and everything else keyword based. This allows me to pass the kwargs as I receive them without unpacking. It is the processor's job.
For the extra files, make a copy of the kwargs and replace the remote file url with the local file location. This way, the extra files are a part of the kwargs dict itself.
defrun_task(action,input_file,*args,**kwargs):params=kwargs.copy()# Get the input file from a URL
log=create_logitem()try:file=get_input_file(input_file)ifaction=="action_2":params["extra_file"]=get_input_file(kwargs["extra_file"]# update the files in params
except:log.status="Failure"# process the input file
try:processor=processors[action](file)results=processor.execute(**params)# Unpack and pass the params
except:log.status="Failure"# upload the results to another location
try:upload_result_file(results.file)except:log.status="Failure"# Post the log about the entire process to a webhoook
post_results_to_webhook(log)
Now I have the same lean structure as I originally had. The only processor specific code is the file downloads which I think I can live with for now.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I solved it by making two important changes:
kwargs
as I receive them without unpacking. It is the processor's job.Now I have the same lean structure as I originally had. The only processor specific code is the file downloads which I think I can live with for now.