(obj, user, stream=None, data={}, uid="", project=None, create=False, save=True)
return result
Update an existing recipe using data found in data dict.
Update an existing recipe using data found in data dict.
Update an existing recipe using data found in data dict .
def update_recipe(obj, user, stream=None, data={}, uid="", project=None, create=False, save=True):
    """
    Update an existing recipe using data found in data dict.
    """

    if not obj and create:
        obj = create_analysis(project=project, user=user, uid=uid)
    elif not obj:
        return

    try:
        data = data or json.load(stream)
    except Exception as exc:
        return {'error': f"Error loading json: {exc}"}

    obj.json_text = data.get('json', obj.json_text)
    obj.template = data.get('template', obj.template)
    obj.name = data.get('name', obj.name)
    obj.text = data.get('text', obj.text)

    # Fetch the base64 image string and write to file.
    strimg = data.get('image')

    if strimg:
        overwrite_image(obj=obj, strimg=strimg)

    # Swap the binary image
    if save:
        obj.save()

    result = obj.api_data

    return result
def update_recipe ( obj , user , stream = None , data = { } , uid = "" , project = None , create = False , save = True ) : if not obj and create : obj = create_analysis ( project = project , user = user , uid = uid ) elif not obj : return try : data = data or json . load ( stream ) except Exception as exc : return { 'error' : f"Error loading json: {exc}" } obj . json_text = data . get ( 'json' , obj . json_text ) obj . template = data . get ( 'template' , obj . template ) obj . name = data . get ( 'name' , obj . name ) obj . text = data . get ( 'text' , obj . text ) # Fetch the base64 image string and write to file. strimg = data . get ( 'image' ) if strimg : overwrite_image ( obj = obj , strimg = strimg ) # Swap the binary image if save : obj . save ( ) result = obj . api_data return result