Skip to content

Rework local openml directory - #987

Merged
PGijsbers merged 4 commits into
developfrom
fix_883_884_906_972
Feb 10, 2021
Merged

Rework local openml directory#987
PGijsbers merged 4 commits into
developfrom
fix_883_884_906_972

Conversation

@mfeurer

Copy link
Copy Markdown
Collaborator

Closes#883#884#906#972

What does this PR implement/fix? Explain your changes.

How should this PR be tested?

Unit tests.

Any other comments?

@mitar does this resolve the issues you had with the package?

@PhMueller does this help you using OpenML inside HPOlib?

Comment threadopenml/config.py Outdated
try:
os.mkdir(expanded_openml_dir)
except PermissionError:
warnings.warn(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer using logging module here.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code to use logging instead of warnings.

Comment threadopenml/utils.py Outdated
os.makedirs(cache_dir, exist_ok=True)
except Exception as e:
raise openml.exceptions.OpenMLCacheException(
f"Cannot create cache directory {cache_dir} due to exception {e}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do not need to have due to exception {e} because you have from e later on.

Copy link
Copy Markdown
CollaboratorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense.

@mitar

mitar commented Oct 30, 2020

Copy link
Copy Markdown
Member

Not fully. My main issue is that OpenML initializes stuff at package import and not on first use. So people who would not even use OpenML codepath in our package (which depends on openml) get an exception (or with this PR a warning).

I do not think you should be calling in config.py:

_setup()
_create_log_handlers()

You should call those at first call which requires any of those. See:

log_path = os.path.join(cache_directory, "openml_python.log")

If cache directory is not writable, this will fail, no? And it is called from _create_log_handlers(), always, for everyone.

@mitar

Copy link
Copy Markdown
Member

@PhMueller

Copy link
Copy Markdown

@mfeurer: Thanks for the notification. Looks fine by me.

@joaquinvanschoren

Copy link
Copy Markdown
Contributor

@mfeurer Would you have time to look at this or should we ask someone else?

@mfeurer

Copy link
Copy Markdown
CollaboratorAuthor

Alright, thanks for your suggestions @mitar. I tried to incorporate them as much as possible, but I'm afraid I didn't do all you asked for.

Not fully. My main issue is that OpenML initializes stuff at package import and not on first use. So people who would not even use OpenML codepath in our package (which depends on openml) get an exception (or with this PR a warning).

I agree that this might be nicer. On the other hand, I think the current solution is more in the spirit of 'fail fast' and gives a warning as quickly as possible. In any case, I currently don't have the time to work on this, wouldn't know how to achieves this and think the changes in this PR cover most use cases and issues and will for now leave it is at is (unless there's an issue with my recent changes).

If cache directory is not writable, this will fail, no? And it is called from _create_log_handlers(), always, for everyone.

I made this conditional on the cache directory being writable, so there shouldn't be any failure from this.

Tests might fail because the server is very flaky at the moment, so we probably have to rebase this on #1000 and rerun.

@mfeurer

Copy link
Copy Markdown
CollaboratorAuthor

@PGijsbers do you think you could have a look at the Windows failures? I believe it'll be much easier to debug for you on a Windows machine than for me by pushing to github

@mitarmitar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. This looks great now.

@PGijsbers
PGijsbers merged commit 47cda65 into developFeb 10, 2021
@PGijsbers
PGijsbers deleted the fix_883_884_906_972 branch February 10, 2021 14:33
@PGijsbersPGijsbers mentioned this pull request Apr 9, 2021
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants

@mfeurer@mitar@PhMueller@joaquinvanschoren@PGijsbers