Skip to content

dvc: refactor config#3298

Merged
efiop merged 5 commits into
treeverse:masterfrom
Suor:config
Feb 13, 2020
Merged

dvc: refactor config#3298
efiop merged 5 commits into
treeverse:masterfrom
Suor:config

Conversation

@Suor
Copy link
Copy Markdown
Contributor

@Suor Suor commented Feb 10, 2020

Advantages:

  • read like a dict
  • modify as a dict for testing or manipulation purposes
  • wrap modifications into context manager to save them:
    with config.edit("local") as conf:
        conf["core"]["remote"] = "new-default"

Design decisions:

  • dropped string constants
  • remote sections are parsed into a simple subdict upon load
  • remote config schema is now defined by url scheme
  • relative paths are handled transparently upon load/save
  • user config and remote manipulations are moved to commands
  • same dev manipulations are done by simply modifying a config dict

@Suor Suor requested a review from efiop February 10, 2020 15:54
@efiop
Copy link
Copy Markdown
Contributor

efiop commented Feb 10, 2020

@Suor Looks amazing! Please check the tests though, looks like slight hickup with schemas for some remotes.

@Suor
Copy link
Copy Markdown
Contributor Author

Suor commented Feb 10, 2020

@efiop I see two issues:

  • setting type for hdfs remote fails, which makes sense, tests need to be adjusted
  • windows paths not being recognized sometimes by validation

I will fix these tomorrow.

@efiop efiop added refactoring Factoring and re-factoring p1-important Important, aka current backlog of things to do labels Feb 11, 2020
@efiop
Copy link
Copy Markdown
Contributor

efiop commented Feb 11, 2020

@Suor Please rebase.

@Suor
Copy link
Copy Markdown
Contributor Author

Suor commented Feb 11, 2020

@efiop rebased

Copy link
Copy Markdown
Contributor

@pared pared left a comment

Choose a reason for hiding this comment

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

One question

Comment thread dvc/remote/s3.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't here be config.get("sse","")? And if not, why do we do config.get("acl","")?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doesn't matter really until it's boolean false it won't be used anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed "" for consistency.

Comment thread dvc/remote/local.py Outdated
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Suor You might've lost _cwd logic, which was resolving relative paths based on config location. Or am I missing something here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I thought that we have test for this 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is not needed anymore:

relative paths are handled transparently upon load/save

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@Suor Could you please refer me to some part of the code?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nevermind, I see it now.

Suor added 4 commits February 13, 2020 23:41
Advantages:
- read like a dict
- modify as a dict for testing or manipulation purposes
- wrap modifications into context manager to save them:

    with config.edit("local") as conf:
        conf["core"]["remote"] = "new-default"

Design decisions:
- dropped string constants
- remote sections are parsed into a simple subdict upon load
- remote config schema is now defined by url scheme
- relative paths are handled transparently upon load/save
- user config and remote manipulations are moved to commands
- same dev manipulations are done by simply modifying a config dict
@efiop
Copy link
Copy Markdown
Contributor

efiop commented Feb 13, 2020

@Suor Please check the DS and CC reports, there are some good points there.

Comment thread dvc/config.py Outdated
def resolve(path):
if os.path.isabs(path) or re.match(r"\w+://", path):
return path
return RelPath(os.path.join(cwd, path))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cwd is defined after this helper in which it is used. This is error-prone.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is minor. Nothing functionally wrong about it because of the same namespace, but causes a mental hickup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Defining subfunction in the middle causes mental hiccup too)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can move it if that worries you.

@Suor
Copy link
Copy Markdown
Contributor Author

Suor commented Feb 13, 2020

@efiop I actually looked them through a couple of days ago) Most of them not introduced by this PR, from the rest:

  • ByUrl complexity here - splitting it is not a good idea
  • not calling dict.__init__() here - Config has very different constructor signature.
  • self in .validate() here and if/elif here just nitpicks, can't cause any issues
  • get_dir() here protected by an assert.

While some stylistic changes can be done, that will bring no value. Diving into DS was a waste of time again.

@efiop
Copy link
Copy Markdown
Contributor

efiop commented Feb 13, 2020

@Suor

ByUrl complexity here - splitting it is not a good idea

👍

not calling dict.init() here - Config has very different constructor signature.

👍

self in .validate() here and if/elif here just nitpicks, can't cause any issues

These are worth fixing, it affects the code style, we avoid such things in other places.

get_dir() here protected by an assert.

👍

While some stylistic changes can be done, that will bring no value. Diving into DS was a waste of time again.

Style is not a waste of time for DVC, please fix those few issues left.

@efiop efiop merged commit 6ccae71 into treeverse:master Feb 13, 2020
@efiop
Copy link
Copy Markdown
Contributor

efiop commented Feb 13, 2020

Thanks @Suor ! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p1-important Important, aka current backlog of things to do refactoring Factoring and re-factoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants