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

refactor: ♻️ major refactor of path functions to be local-first #1114

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lwjohnst86
Copy link
Member

Description

Converts all the path functions to be either local-first or multi-user. In the process I consolidated some of the functions into either "local" or "global" files.

I moved some of the smaller helper functions into the larger files, and appended with _. I'm not a huge fan of how it looks, but given it is a common Python practice and it helps visually separate external from internal functions, I'm ok if we start doing that too.

Closes #1004

This PR needs an in-depth review.

Checklist

  • Added or updated tests
  • Updated documentation
  • Ran just run-all

return check_is_file(path)


def path_resource_raw(resource_id: int, path: Path = Path.cwd()) -> Path:
Copy link
Member

Choose a reason for hiding this comment

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

Following the discussion in #1078 that lead to this issue #1127 this should probably also be renamed:

Suggested change
def path_resource_raw(resource_id: int, path: Path = Path.cwd()) -> Path:
def path_resource_batch(resource_id: int, path: Path = Path.cwd()) -> Path:

Copy link
Contributor

@martonvago martonvago left a comment

Choose a reason for hiding this comment

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

Niiiice! 🎉 🎉 All my comments are very minor!

path=temp_path
)

sp.path_properties(path = temp_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sp.path_properties(path = temp_path)
sp.path_properties(path=temp_path)

path=temp_path
)

sp.path_readme(path = temp_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
sp.path_readme(path = temp_path)
sp.path_readme(path=temp_path)

Comment on lines +113 to +115
resource_path = Path(temp_path / "resources")
resource_path.mkdir()
sp.create_resource_structure(path=resource_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
resource_path = Path(temp_path / "resources")
resource_path.mkdir()
sp.create_resource_structure(path=resource_path)
resources_path = Path(temp_path / "resources")
resources_path.mkdir()
sp.create_resource_structure(path=resources_path)

To avoid confusion with path_resource

Comment on lines +202 to +204
resource_path = Path(temp_path / "resources")
resource_path.mkdir()
sp.create_resource_structure(path=resource_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
resource_path = Path(temp_path / "resources")
resource_path.mkdir()
sp.create_resource_structure(path=resource_path)
resources_path = Path(temp_path / "resources")
resources_path.mkdir()
sp.create_resource_structure(path=resources_path)

Comment on lines +242 to +244
resource_path = Path(temp_path / "resources")
resource_path.mkdir()
sp.create_resource_structure(path=resource_path)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
resource_path = Path(temp_path / "resources")
resource_path.mkdir()
sp.create_resource_structure(path=resource_path)
resources_path = Path(temp_path / "resources")
resources_path.mkdir()
sp.create_resource_structure(path=resources_path)

tmp_path, tmp_package, function, expected_path
):
path = function(path=tmp_path)
# When, then
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "when" is for executing the functionality we're testing (here path = function(path=tmp_path)) and "then" is for the assertions.

(path_readme, "README.md"),
],
)
def test_path_local_root_files_return_expected_path(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_path_local_root_files_return_expected_path(
def test_path_local_root_functions_return_expected_path(

Or am I misunderstanding?

"function",
[path_properties, path_readme],
)
def test_path_local_root_files_raise_error_if_files_not_exist(tmp_package, function):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def test_path_local_root_files_raise_error_if_files_not_exist(tmp_package, function):
def test_path_local_root_functions_raise_error_if_files_not_exist(tmp_package, function):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Revise path functions to use the 'local first' split
3 participants