Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX assign study's id to study_id instead of id #782

Merged
merged 1 commit into from
Sep 20, 2019
Merged

Conversation

PGijsbers
Copy link
Collaborator

A study's id would be assigned to id on initialization, and to study_id after publish. Now it is uniformly always study_id, following the other openml-python objects (e.g. run.run_id).

@PGijsbers
Copy link
Collaborator Author

PGijsbers commented Sep 19, 2019

Restarting the scikit-learn 0.21 test after getting an (what I think is) unrelated error:

=================================== FAILURES ===================================

___________________________ TestTask.test__get_task ____________________________

[gw2] linux -- Python 3.7.4 /home/travis/miniconda/envs/testenv/bin/python
self = <tests.test_tasks.test_task_functions.TestTask testMethod=test__get_task>
    def test__get_task(self):
        openml.config.cache_directory = self.static_cache_dir
>       openml.tasks.get_task(1882)

/home/travis/build/openml/openml-python/tests/test_tasks/test_task_functions.py:123: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

/home/travis/build/openml/openml-python/openml/utils.py:328: in safe_func
    return func(*args, **kwargs)
/home/travis/build/openml/openml-python/openml/tasks/functions.py:378: in get_task
    raise e
/home/travis/build/openml/openml-python/openml/tasks/functions.py:372: in get_task
    task.download_split()
/home/travis/build/openml/openml-python/openml/tasks/task.py:132: in download_split
    split = OpenMLSplit._from_arff_file(cached_split_file)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'openml.tasks.split.OpenMLSplit'>
filename = '/home/travis/build/openml/openml-python/tests/files/org/openml/test/tasks1882/datasplits.arff'
    @classmethod

    def _from_arff_file(cls, filename: str) -> 'OpenMLSplit':  
        repetitions = None
        pkl_filename = filename.replace(".arff", ".pkl.py3")
        if os.path.exists(pkl_filename):
            with open(pkl_filename, "rb") as fh:
>               _ = pickle.load(fh)
E               EOFError: Ran out of input

/home/travis/build/openml/openml-python/openml/tasks/split.py:77: EOFError

___________________________ OpenMLSplitTest.test_eq ____________________________

[gw0] linux -- Python 3.7.4 /home/travis/miniconda/envs/testenv/bin/python
self = <tests.test_tasks.test_split.OpenMLSplitTest testMethod=test_eq>
    def test_eq(self):
        split = OpenMLSplit._from_arff_file(self.arff_filename)
        self.assertEqual(split, split) 
>       split2 = OpenMLSplit._from_arff_file(self.arff_filename)

/home/travis/build/openml/openml-python/tests/test_tasks/test_split.py:35: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'openml.tasks.split.OpenMLSplit'>
filename = '/home/travis/build/openml/openml-python/tests/test_tasks/../files/org/openml/test/tasks/1882/datasplits.arff'
    @classmethod
    def _from_arff_file(cls, filename: str) -> 'OpenMLSplit':
        repetitions = None
        pkl_filename = filename.replace(".arff", ".pkl.py3")
        if os.path.exists(pkl_filename):
            with open(pkl_filename, "rb") as fh:
                _ = pickle.load(fh)
            repetitions = _["repetitions"]
            name = _["name"]    

        # Cache miss
        if repetitions is None:
            # Faster than liac-arff and sufficient in this situation!
            if not os.path.exists(filename):
                raise FileNotFoundError(
>                   'Split arff %s does not exist!' % filename
                )
E               FileNotFoundError: Split arff /home/travis/build/openml/openml-python/tests/test_tasks/../files/org/openml/test/tasks/1882/datasplits.arff does not exist!

/home/travis/build/openml/openml-python/openml/tasks/split.py:86: FileNotFoundError

_____________________ OpenMLSplitTest.test_from_arff_file ______________________

[gw0] linux -- Python 3.7.4 /home/travis/miniconda/envs/testenv/bin/python
self = <tests.test_tasks.test_split.OpenMLSplitTest testMethod=test_from_arff_file>
    def test_from_arff_file(self):
>       split = OpenMLSplit._from_arff_file(self.arff_filename)
/home/travis/build/openml/openml-python/tests/test_tasks/test_split.py:52: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'openml.tasks.split.OpenMLSplit'>

filename = '/home/travis/build/openml/openml-python/tests/test_tasks/../files/org/openml/test/tasks/1882/datasplits.arff'

    @classmethod

    def _from_arff_file(cls, filename: str) -> 'OpenMLSplit':

    

        repetitions = None

    

        pkl_filename = filename.replace(".arff", ".pkl.py3")

    

        if os.path.exists(pkl_filename):

            with open(pkl_filename, "rb") as fh:

                _ = pickle.load(fh)

            repetitions = _["repetitions"]

            name = _["name"]

    

        # Cache miss

        if repetitions is None:

            # Faster than liac-arff and sufficient in this situation!

            if not os.path.exists(filename):

                raise FileNotFoundError(

>                   'Split arff %s does not exist!' % filename

                )

E               FileNotFoundError: Split arff /home/travis/build/openml/openml-python/tests/test_tasks/../files/org/openml/test/tasks/1882/datasplits.arff does not exist!

/home/travis/build/openml/openml-python/openml/tasks/split.py:86: FileNotFoundError

_________ OpenMLTaskMethodsTest.test_get_train_and_test_split_indices __________

[gw2] linux -- Python 3.7.4 /home/travis/miniconda/envs/testenv/bin/python

tid = 1882

    def _get_cached_task(tid: int) -> OpenMLTask:

        """Return a cached task based on the given id.

    

        Parameters

        ----------

        tid : int

            Id of the task.

    

        Returns

        -------

        OpenMLTask

        """

        tid_cache_dir = openml.utils._create_cache_directory_for_id(

            TASKS_CACHE_DIR_NAME,

            tid

        )

    

        try:

>           with io.open(os.path.join(tid_cache_dir, "task.xml"), encoding='utf8')\

                    as fh:

E                   FileNotFoundError: [Errno 2] No such file or directory: '/home/travis/build/openml/openml-python/tests/files/org/openml/test/tasks/1882/task.xml'

/home/travis/build/openml/openml-python/openml/tasks/functions.py:72: FileNotFoundError

During handling of the above exception, another exception occurred:

task_id = 1882

    def _get_task_description(task_id):

    

        try:

>           return _get_cached_task(task_id)

/home/travis/build/openml/openml-python/openml/tasks/functions.py:386: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

tid = 1882

    def _get_cached_task(tid: int) -> OpenMLTask:

        """Return a cached task based on the given id.

    

        Parameters

        ----------

        tid : int

            Id of the task.

    

        Returns

        -------

        OpenMLTask

        """

        tid_cache_dir = openml.utils._create_cache_directory_for_id(

            TASKS_CACHE_DIR_NAME,

            tid

        )

    

        try:

            with io.open(os.path.join(tid_cache_dir, "task.xml"), encoding='utf8')\

                    as fh:

                return _create_task_from_xml(fh.read())

        except (OSError, IOError):

            openml.utils._remove_cache_dir_for_id(TASKS_CACHE_DIR_NAME,

                                                  tid_cache_dir)

            raise OpenMLCacheException("Task file for tid %d not "

>                                      "cached" % tid)

E           openml.exceptions.OpenMLCacheException: Task file for tid 1882 not cached

/home/travis/build/openml/openml-python/openml/tasks/functions.py:79: OpenMLCacheException

During handling of the above exception, another exception occurred:

self = <tests.test_tasks.test_task_methods.OpenMLTaskMethodsTest testMethod=test_get_train_and_test_split_indices>

    def test_get_train_and_test_split_indices(self):

        openml.config.cache_directory = self.static_cache_dir

>       task = openml.tasks.get_task(1882)

/home/travis/build/openml/openml-python/tests/test_tasks/test_task_methods.py:31: 

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

/home/travis/build/openml/openml-python/openml/utils.py:328: in safe_func

    return func(*args, **kwargs)

/home/travis/build/openml/openml-python/openml/tasks/functions.py:378: in get_task

    raise e

/home/travis/build/openml/openml-python/openml/tasks/functions.py:360: in get_task

    task = _get_task_description(task_id)

/home/travis/build/openml/openml-python/openml/tasks/functions.py:396: in _get_task_description

    'get')

/home/travis/build/openml/openml-python/openml/_api_calls.py:51: in _perform_api_call

    return _read_url(url, request_method, data)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

url = 'https://test.openml.org/api/v1/xml/task/1882', request_method = 'get'

data = {'api_key': '610344db6388d9ba34f6db45a3cf71de'}

    def _read_url(url, request_method, data=None):

        data = {} if data is None else data

        if config.apikey is not None:

            data['api_key'] = config.apikey

    

        response = send_request(request_method=request_method, url=url, data=data)

        if response.status_code != 200:

>           raise _parse_server_exception(response, url)

E           openml.exceptions.OpenMLServerException: Unknown task

/home/travis/build/openml/openml-python/openml/_api_calls.py:98: OpenMLServerException

@codecov-io
Copy link

codecov-io commented Sep 19, 2019

Codecov Report

Merging #782 into develop will decrease coverage by 0.02%.
The diff coverage is 25%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #782      +/-   ##
===========================================
- Coverage    87.71%   87.69%   -0.03%     
===========================================
  Files           36       36              
  Lines         4177     4177              
===========================================
- Hits          3664     3663       -1     
- Misses         513      514       +1
Impacted Files Coverage Δ
openml/study/study.py 64.36% <25%> (ø) ⬆️
openml/_api_calls.py 83.11% <0%> (-1.3%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afc7445...c046f59. Read the comment docs.

@mfeurer mfeurer merged commit 5cc1638 into develop Sep 20, 2019
@mfeurer mfeurer deleted the study_id branch September 20, 2019 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants