Skip to content

Commit

Permalink
Introduce pg.io for abstracted IO operations.
Browse files Browse the repository at this point in the history
Details:
- Introduces `pg.io.File` and `pg.io.FileSystem`
- Introduces `pg.io.StdFileSystem` and `pg.io.MemoryFileSystem`.
- Introduces unified APIs for file access.
PiperOrigin-RevId: 584335843
  • Loading branch information
daiyip authored and pyglove authors committed Nov 21, 2023
1 parent ee6009b commit b367568
Show file tree
Hide file tree
Showing 6 changed files with 721 additions and 14 deletions.
1 change: 1 addition & 0 deletions docs/api/docgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
'detouring',
'geno',
'hyper',
'io',
'patching',
'object_utils',
'symbolic',
Expand Down
25 changes: 16 additions & 9 deletions pyglove/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
# pylint: disable=reimported
# pylint: disable=g-import-not-at-top


#
# Symbols from 'symbolic.py'
# Symbols from 'symbolic' sub-module.
#


Expand Down Expand Up @@ -174,7 +175,7 @@
WritePermissionError = symbolic.WritePermissionError

#
# Symbols from 'typing.py'
# Symbols from 'typing' sub-module.
#

# NOTE(daiyip): we introduce 'typing' as an alias for 'schema' sub-module, since
Expand All @@ -195,7 +196,7 @@


#
# Symbols from 'geno.py'.
# Symbols from 'geno' sub-module.
#

from pyglove.core import geno
Expand All @@ -208,7 +209,7 @@


#
# Symbols from 'hyper.py'.
# Symbols from 'hyper' sub-module.
#

from pyglove.core import hyper
Expand Down Expand Up @@ -237,7 +238,7 @@


#
# Symbols from 'tuning.py'.
# Symbols from 'tuning' sub-module.
#

from pyglove.core import tuning
Expand All @@ -246,15 +247,15 @@


#
# Symbols from 'detouring.py'
# Symbols from 'detouring' sub-module.
#

from pyglove.core import detouring
detour = detouring.detour


#
# Symbols from 'patching.py'.
# Symbols from 'patching' sub-module.
#

from pyglove.core import patching
Expand All @@ -270,7 +271,7 @@


#
# Symbols from 'object_utils.py'.
# Symbols from 'object_utils' sub-module.
#

from pyglove.core import object_utils
Expand All @@ -291,13 +292,19 @@
docstr = object_utils.docstr
catch_errors = object_utils.catch_errors

#
# Symbols from `io` sub-module.
#

from pyglove.core import io


#
# Symbols from `logging.py`.
#

from pyglove.core import logging


# pylint: enable=g-import-not-at-top
# pylint: enable=reimported
# pylint: enable=unused-import
Expand Down
20 changes: 20 additions & 0 deletions pyglove/core/io/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2023 The PyGlove Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Pluggable IO with unified interfaces."""

# pylint: disable=g-bad-import-order

from pyglove.core.io.file_system import *

# pylint: enable=g-bad-import-order
Loading

0 comments on commit b367568

Please sign in to comment.