<commit_before>const {map, switchMap} = require('rx/operators')
const http = require('sepal/httpClient')
const imageFactory = require('sepal/ee/imageFactory')
const {context} = require('sepal/context')
const log = require('sepal/log').getLogger('task')


const recipeRef = ({id}) => {
    log.warn('creating recipeRef', id)
    const recipe$ = loadRecipe$(id)
    return {
        getImage$() {
            return recipe$.pipe(
                switchMap(recipe => recipe.getImage$())
            )
        },
        getVisParams$() {
            return recipe$.pipe(
                switchMap(recipe => recipe.getVisParams$())
            )
        },
        getGeometry$() {
            return recipe$.pipe(
                switchMap(recipe => recipe.getGeometry$())
            )
        }
    }
}

const loadRecipe$ = id =>
    http.get$(`${context().sepalHost}/api/processing-recipes/${id}`, {
        username: context().sepalUsername,
        password: context().sepalPassword
    }).pipe(
        map(response => JSON.parse(response.body)),
        map(recipe => {
            log.warn('recipe', recipe)
            return imageFactory(recipe);
        })
    )

module.exports = recipeRef<commit_msg>Corrected recipe endpoint url.<commit_after>const {map, switchMap} = require('rx/operators')
const http = require('sepal/httpClient')
const imageFactory = require('sepal/ee/imageFactory')
const {context} = require('sepal/context')
const log = require('sepal/log').getLogger('task')


const recipeRef = ({id}) => {
    log.warn('creating recipeRef', id)
    const recipe$ = loadRecipe$(id)
    return {
        getImage$() {
            return recipe$.pipe(
                switchMap(recipe => recipe.getImage$())
            )
        },
        getVisParams$() {
            return recipe$.pipe(
                switchMap(recipe => recipe.getVisParams$())
            )
        },
        getGeometry$() {
            return recipe$.pipe(
                switchMap(recipe => recipe.getGeometry$())
            )
        }
    }
}

const loadRecipe$ = id =>
    http.get$(`https://${context().sepalHost}/api/processing-recipes/${id}`, {
        username: context().sepalUsername,
        password: context().sepalPassword
    }).pipe(
        map(response => JSON.parse(response.body)),
        map(recipe => {
            log.warn('recipe', recipe)
            return imageFactory(recipe);
        })
    )

module.exports = recipeRef
{'fraction_non_alphanumeric': 0.15132924335378323, 'fraction_numerical': 0.0, 'mean_word_length': 2.172503242542153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6064801', 'n_tokens_mistral': 702, 'n_tokens_neox': 694, 'n_words': 120}