Skip to content

Commit

Permalink
Issue #74: Update coverage for test_datasets.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
bongjinkoo committed May 17, 2022
1 parent 61e6fbc commit 9039ec6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions ioSPI/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ class OSFProject:
Parameters
----------
username : str
username : str, default = None
Username corresponding to an account on OSF.
E.g. email address used to create an OSF account.
token : str
token : str, default = None
Personal token from osf.io.
See: https://osf.io/settings/tokens
project_id : str, default = "xbr2m"
Identifier of the project, found on the OSF project page.
E.g. xbr2m for project at https://osf.io/xbr2m/
storage : str, default = "osfstorage"
Storage provider of the project.
osfclient_path : str, default = None
See Also
--------
Expand All @@ -34,7 +35,7 @@ def __init__(
token: str = None,
project_id: str = "xbr2m",
storage: str = "osfstorage",
osflient_path: str = None,
osfclient_path: str = None,
) -> None:
if username is None:
raise TypeError("username must be provided.")
Expand All @@ -46,9 +47,9 @@ def __init__(

self.project_id = project_id
self.storage = storage
self.osfclient_path = osflient_path
self.osfclient_path = osfclient_path
self.osfclient_command = "osf "
if osflient_path is not None:
if osfclient_path is not None:
self.osfclient_command = self.osfclient_path + self.osfclient_command

config_path = os.path.join(".osfcli.config")
Expand All @@ -70,18 +71,18 @@ def ls(self):
stdout=subprocess.PIPE,
).stdout

def download(self, remote_path: str, local_path: str):
def download(self, remote_path: str = None, local_path: str = None):
"""Download a file from an OSF project and save it locally.
Parameters
----------
remote_path : str
remote_path : str, default = None
Remote path of the file in an OSF project,
which will be appended to the project storage name (by default, osfstorage).
E.g. osfstorage/
randomrot1D_nodisorder/
4v6x_randomrot_copy6_defocus3.0_yes_noise.txt
local_path : str
local_path : str, default = None
Local path where the file will be saved.
E.g. 4v6x_randomrot_copy6_defocus3.0_yes_noise.txt
"""
Expand All @@ -101,7 +102,7 @@ def download(self, remote_path: str, local_path: str):
)
print("Done!")

def upload(self, local_path: str, remote_path: str):
def upload(self, local_path: str = None, remote_path: str = None):
"""Upload a file to an OSF project.
Notes
Expand All @@ -110,10 +111,10 @@ def upload(self, local_path: str, remote_path: str):
Parameters
----------
local_path : str
local_path : str, default = None
Local path where the file will be saved.
E.g. 4v6x_randomrot_copy6_defocus3.0_yes_noise.txt
remote_path : str
remote_path : str, default = None
Remote path of the file in an OSF project,
which will be appended to the project storage name (by default, osfstorage).
E.g. osfstorage/
Expand All @@ -137,12 +138,12 @@ def upload(self, local_path: str, remote_path: str):
print(io.StringIO(f).readlines())
print("Done!")

def remove(self, remote_path: str):
def remove(self, remote_path: str = None):
"""Remove a file in an OSF project.
Parameters
----------
remote_path : str
remote_path : str, default = None
Remote path of the file to remove in an OSF project,
which will be appended to the project storage name (by default, osfstorage).
E.g. osfstorage/
Expand Down

0 comments on commit 9039ec6

Please sign in to comment.