openml / openml-java

Java library to interface with OpenML
10 stars 4 forks source link

Error while connecting using API #8

Closed nodechef closed 7 years ago

nodechef commented 7 years ago

Hi everyone. I'm trying to connect to download dataset using my java application and I'm following the JAVA API documentation. But I'm getting an error. Can some please figure out why it's throwing an error.

image

This is the error.

image 1 image 2

janvanrijn commented 7 years ago

My apologies for the slow reply, it's deadline week ..

My conjecture is the following: As a result of not setting the OpenML server URL (different constructor of the OpenML Connector object) a default is picked. Probably in your case it's http://www.openml.org/ (set somewhere in org.openml.apiconnector.settings.Settings.java). However, this URL is outdated, and should be replaced by https://www.openml.org/ (note the https vs http)

I will make a new release soon that fixes this default issue.

joaquinvanschoren commented 7 years ago

In that case you could fix it by creating a folder '.openml' in your home folder, with a file 'openml.conf' with the following content:

server = https://www.openml.org/ api_key = YOURKEY

Obviously, replace YOURKEY with your API key ;)

On Mon, May 29, 2017 at 3:51 PM janvanrijn notifications@github.com wrote:

My apologies for the slow reply, it's deadline week ..

My conjecture is the following: As a result of not setting the OpenML server URL (different constructor of the OpenML Connector object) a default is picked. Probably in your case it's http://www.openml.org/ (set somewhere in org.openml.apiconnector.settings.Settings.java). However, this URL is outdated, and should be replaced by https://www.openml.org/ (note the https vs http)

I will make a new release soon that fixes this default issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openml/java/issues/8#issuecomment-304665894, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpQVytVcedjCt2_s1MuNBm9oIoYlORwks5r-s1PgaJpZM4Nk12C .

-- Thank you, Joaquin

nodechef commented 7 years ago

Hi Jan,

I'm still getting an error. According to your instructions, this is how I did it. image

image

image

P.S I don't care about the api_key, I'll reset it once it stops giving error.

Regards, Sami Ullah Chattha

On 29 May 2017 at 20:51, Joaquin Vanschoren notifications@github.com wrote:

In that case you could fix it by creating a folder '.openml' in your home folder, with a file 'openml.conf' with the following content:

server = https://www.openml.org/ api_key = YOURKEY

Obviously, replace YOURKEY with your API key ;)

On Mon, May 29, 2017 at 3:51 PM janvanrijn notifications@github.com wrote:

My apologies for the slow reply, it's deadline week ..

My conjecture is the following: As a result of not setting the OpenML server URL (different constructor of the OpenML Connector object) a default is picked. Probably in your case it's http://www.openml.org/ (set somewhere in org.openml.apiconnector.settings.Settings.java). However, this URL is outdated, and should be replaced by https://www.openml.org/ (note the https vs http)

I will make a new release soon that fixes this default issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openml/java/issues/8#issuecomment-304665894, or mute the thread https://github.com/notifications/unsubscribe-auth/ABpQVytVcedjCt2_ s1MuNBm9oIoYlORwks5r-s1PgaJpZM4Nk12C .

-- Thank you, Joaquin

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/openml/java/issues/8#issuecomment-304691094, or mute the thread https://github.com/notifications/unsubscribe-auth/AQslkTRfjXmtsTC7nsUOgi9_mxbwCcOfks5r-umDgaJpZM4Nk12C .

-- Best Regards, Sami Ullah Chattha

janvanrijn commented 7 years ago

I can't see the images

nodechef commented 7 years ago

Can you see the images now ?

janvanrijn commented 7 years ago

Little typo, the file is supposed to be openml.conf (then it should work)

As an alternative solution, you could use a different constructor, the one that also accepts the 'server' attribute (and then, of course, give it "https://www.openml.org/" as input)

nodechef commented 7 years ago

This first solution doesn't seems to work.

image

And are you talking about this constructor method ?

image

nodechef commented 7 years ago

This is also not working. image

janvanrijn commented 7 years ago

Documentation is a bit outdated, sorry for that.

Which version of the apiconnector are you using? If you are using version 1.0.13 (most recent on maven central)

nodechef commented 7 years ago

It's version 1.0.13. image

janvanrijn commented 7 years ago

My code: (after also installing some mandatory other dependecies, such as xstream, apache IO and apache httpclient - if you use maven, maven takes care of it):

import org.openml.apiconnector.io.OpenmlConnector;
import org.openml.apiconnector.xml.DataSetDescription;

public class Openml {

    public static void main(String[] args) throws Exception {
        OpenmlConnector openml = new OpenmlConnector("https://www.openml.org/", "yourkey");
        DataSetDescription dsd = openml.dataGet(61);

        System.out.println("dataset name: " + dsd.getName()); // output = "dataset name: iris"
    }
}

One other failure mode is that the openml cache directory contains rubish, would be good to delete the .openml/cache folder

nodechef commented 7 years ago

Thank you so much man. This constructor worked.