Skip to content

Instantly share code, notes, and snippets.

View JPDSousa's full-sized avatar

João Sousa JPDSousa

  • Lisbon, Portugal
View GitHub Profile
from collections import OrderedDict
from typing import Dict, Any, Mapping
from django.core.exceptions import ValidationError as DjangoValidationError
from rest_framework import serializers
from rest_framework.fields import set_value, get_error_detail, SkipField
from rest_framework.exceptions import ValidationError
from rest_framework.settings import api_settings
@JPDSousa
JPDSousa / H2OModelProviderLoadTest.java
Created November 26, 2018 15:13
Race condition debuging in OpenML H2O Provider
@Test
public void testParallelScoring() throws ModelLoadingException, ExecutionException, InterruptedException {
final ExecutorService executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() + 1);
final ClassificationH2OModel firstModel = getFirstModel();
final Instance oneInstance = getDummyInstance();
final Instance anotherInstance = getDummyInstanceDifferentResult();
//The expected values -> scored in the same thread.
final double[] oneExpected = firstModel.getClassDistribution(oneInstance);
final double[] otherExpected = firstModel.getClassDistribution(anotherInstance);