0
votes

I'm appending dozens of slides to presentations with a simple app script :

  var presentation_to = SlidesApp.openById(presentation_to_id);
  var presentation_from = SlidesApp.openById(presentation_from_id);
  var slide = presentation_from.getSlideById(slide_id);      
  var newSlide = presentation_to.appendSlide(slide); 

I have an app script API endpoint for that.

I started with one app script that would loop through all the slides IDs, but this had terrible performance and would timeout after 5 minutes. I've split my calls to the API app script to ask for one slide at a time, with parallelization (so I run several request to add a slide to the same presentation at once).

When the slides have big pictures in them, I still end up getting this :

Google::Apis::TransmissionError: execution expired

Is appendSlide() performance so bad what I want to do is not possible, or is there a way for me to make it work without having to wait 1h to generate one 50 slides presentation ?

PS : You'll find attached the logs of the script. Each line is meant to append ONE slide to a presentation (always the same destination). The execution times and error rates are just through the roof. Is performance simply limited by Google or is there a way to bypass this issue ?

1
Although I thought that you might want to reduce the process cost of your script, in order to correctly understand about your question, can I ask you about the relationship between your current issue and your script in your question? From the error message, you might run the Google Apps Script with ruby. But, I cannot understand about your detail situation. This is due to my poor skill. I deeply apologize for this. - Tanaike
Take a look at using batchupdate method. - Cooper
@Rubén the 4 lines of code are enough show the effect, but to see the logs you would need to create a script with those lines on script.google.com. Then the goal is to import a slide with a heavy picture, and launch the app script several times. Tanaike the issue is when I call this script as an API endpoint a lot of times in parallel, because I need to append a lot of slides to a specific presentation Cooper batchUpdate unfortunately does not handle appendSlide() :( It really looks like there's a performance threshold on that function :/ - Alb Dum

1 Answers

0
votes

Considerations

Using Apps Script SlideApp built-in Class you are basically creating an API call every time you run .appendSlide() method. This will cause big network overhead when your script inserts a lot of slides.

Generally this is solved by using batch requests via Advanced Google Services. Unfortunately, there is no method to create a Page copy request that you could insert in a batch operation. If this is really important for your workflow you should consider filing a Feature Request

Reference

Slides API