Change Project image through code

SanderVW
SanderVW Registered Posts: 47 ✭✭✭✭

This might be a bit of a silly question, but is there a possibility to change the image used for a project through code (or another automated way)?

The reason for this is that, after duplicating projects from Development to Acceptance, we would like to distinguish between them through the image but want to get rid of the manual work of going into every project and changing the image. Through code would be preferred but if there is a way to do this through, for instance, scenario's (which I wouldn't expect) that would be great too!

Is there a way to do this?


Operating system used: Windows

Tagged:

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,103 Neuron

    I don't think you can modify the image via the Dataiku API but this seems to work for me. If the project has an image it will be placed here:

    dss_home/config/projects/project_id/pictures/project-original.png

    If the project doesn't have an image set then the pictures directory may not exist. You can create it and place an image on it and refresh DSS and it will show the image. The image needs to be named project-original.png, be of png format and have 364x910 pixels and 72 ppi. You can upload any other images you want to use to a dummy project and that will generate the png image with the right size. Or if you want to be even cooler about it you could use some image tools to add a watermark in diagonal to the image automatically (ie Development, Testing, Production, etc). You could automate this either using Python or a Shell recipe.

    Personally I think this trying to reinvent the wheel. This is exactly what the project status is for and if you need more metadata you can use project tags. Both of these are directly available in the Dataiky Python API so you can update them easily as you move projects using Deployer's built-in post-deployment hook.

  • SanderVW
    SanderVW Registered Posts: 47 ✭✭✭✭

    You mention using python code to add watermarks to the image. How would you use python code to change the image? Not specifically the watermark but getting the image from the project properties through code and uploading a new version of it through code.

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,103 Neuron

    As I said there is no APIs for this but Dataiku stores the files in the directory I mentioned so you can write Python code that copies/modifies the images as required and any changes done will be displayed in the DSS interface. Plenty of examples on the web on how to copy files using Python. With regards to watermarking Python Pillow seems to be a popular library for watermarking images with Python:

    https://www.blog.pythonlibrary.org/2017/10/17/how-to-watermark-your-photos-with-python/

Setup Info
    Tags
      Help me…