@@ -483,7 +483,7 @@ def etag(project_path, project_id=None, object_client=None):
483483
484484
485485@contextlib .contextmanager
486- def open (project_path , mode = "r" , temp_dir = None , ** kwargs ):
486+ def open (project_path , mode = "r" , temp_dir = None , project_id = None , ** kwargs ):
487487 """Open a file from a project's datasets for reading.
488488
489489 This downloads the file into a temporary directory before opening it, so if
@@ -501,9 +501,13 @@ def open(project_path, mode="r", temp_dir=None, **kwargs):
501501 saved into temporarily. Note that on SherlockML servers, the default
502502 temporary directory can break with large files, so if your file is
503503 upwards of 2GB, it is recommended to specify temp_dir='/project'.
504+ project_id : str, optional
505+ The project to get files from. You need to have access to this project
506+ for it to work. Defaults to the project set by FACULTY_PROJECT_ID in
507+ your environment.
504508 """
505509
506- if _isdir (project_path ):
510+ if _isdir (project_path , project_id = project_id ):
507511 raise DatasetsError ("Can't open directories." )
508512
509513 if any (char in mode for char in ("w" , "a" , "x" )):
@@ -513,7 +517,7 @@ def open(project_path, mode="r", temp_dir=None, **kwargs):
513517 local_path = os .path .join (tmpdir , os .path .basename (project_path ))
514518
515519 try :
516- get (project_path , local_path )
520+ get (project_path , local_path , project_id = project_id )
517521 with io .open (local_path , mode , ** kwargs ) as file_object :
518522 yield file_object
519523 finally :
0 commit comments