<commit_before>package org.openforis.sepal.component.dataprovider.retrieval

import org.openforis.sepal.component.dataprovider.DownloadRequest
import org.openforis.sepal.component.dataprovider.SceneProcessor
import org.openforis.sepal.component.dataprovider.SceneRequest
import org.openforis.sepal.component.dataprovider.Status
import org.openforis.sepal.component.dataprovider.retrieval.provider.DownloadRequestObservable
import org.openforis.sepal.component.dataprovider.retrieval.provider.SceneRetrievalObservable
import org.openforis.sepal.util.Is
import org.openforis.sepal.util.Terminal
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import static Status.PROCESSED
import static Status.PROCESSING

class SepalSceneProcessor implements SceneProcessor {
    private static Logger LOG = LoggerFactory.getLogger(this)

    @Delegate
    @SuppressWarnings("GroovyUnusedDeclaration")
    private final SceneRetrievalObservable sceneRetrievalObservable = new SceneRetrievalObservable()

    @Delegate
    @SuppressWarnings("GroovyUnusedDeclaration")
    private final DownloadRequestObservable downloadRequestObservable = new DownloadRequestObservable()

    private final SceneRepository sceneRepository
    private final File scriptsHome

    SepalSceneProcessor(SceneRepository sceneRepository, File scriptsHome) {
        this.sceneRepository = sceneRepository
        this.scriptsHome = scriptsHome
        Is.existingFolder(scriptsHome)
    }

    void process(DownloadRequest downloadRequest, String processingChain) {
        notifyRequestStatusChange(downloadRequest, PROCESSING)
        if (processingChain) {
            doProcess(processingChain, sceneRepository.getDownloadRequestWorkingDirectory(downloadRequest))
        }
        notifyRequestStatusChange(downloadRequest, PROCESSED)
    }

    @Override
    void process(SceneRequest request) {
        LOG.debug("Processing request: $request")
        notifyListeners(request, PROCESSING)
        if (request.processingChain) {
            doProcess(request.processingChain, sceneRepository.getSceneWorkingDirectory(request))
        }
        notifyListeners(request, PROCESSED)
    }

    private void notifyRequestStatusChange(DownloadRequest request, Status status) {<commit_msg>Fixed stack overflow bug.<commit_after>package org.openforis.sepal.component.dataprovider.retrieval

import org.openforis.sepal.component.dataprovider.DownloadRequest
import org.openforis.sepal.component.dataprovider.SceneProcessor
import org.openforis.sepal.component.dataprovider.SceneRequest
import org.openforis.sepal.component.dataprovider.Status
import org.openforis.sepal.component.dataprovider.retrieval.provider.DownloadRequestObservable
import org.openforis.sepal.component.dataprovider.retrieval.provider.SceneRetrievalObservable
import org.openforis.sepal.util.Is
import org.openforis.sepal.util.Terminal
import org.slf4j.Logger
import org.slf4j.LoggerFactory

import static Status.PROCESSED
import static Status.PROCESSING

class SepalSceneProcessor implements SceneProcessor {
    private static Logger LOG = LoggerFactory.getLogger(this)

    @Delegate
    @SuppressWarnings("GroovyUnusedDeclaration")
    private final SceneRetrievalObservable sceneRetrievalObservable = new SceneRetrievalObservable()

    @Delegate
    @SuppressWarnings("GroovyUnusedDeclaration")
    private final DownloadRequestObservable downloadRequestObservable = new DownloadRequestObservable()

    private final SceneRepository sceneRepository
    private final File scriptsHome

    SepalSceneProcessor(SceneRepository sceneRepository, File scriptsHome) {
        this.sceneRepository = sceneRepository
        this.scriptsHome = scriptsHome
        Is.existingFolder(scriptsHome)
    }

    void process(DownloadRequest downloadRequest, String processingChain) {
        notifyRequestStatusChange(downloadRequest, PROCESSING)
        if (processingChain) {
            doProcess(processingChain, sceneRepository.getDownloadRequestWorkingDirectory(downloadRequest))
        }
        notifyRequestStatusChange(downloadRequest, PROCESSED)
    }

    @Override
    void process(SceneRequest request) {
        notifyListeners(request, PROCESSING)
        if (request.processingChain) {
            doProcess(request.processingChain, sceneRepository.getSceneWorkingDirectory(request))
        }
        notifyListeners(request, PROCESSED)
    }

    private void notifyRequestStatusChange(DownloadRequest request, Status status) {
{'fraction_non_alphanumeric': 0.06383928571428571, 'fraction_numerical': 0.0008928571428571428, 'mean_word_length': 4.950863213811421, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2684960', 'n_tokens_mistral': 1182, 'n_tokens_neox': 1155, 'n_words': 208}