Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ The SDK automatically handles all dependency packaging for Data Cloud deployment

**No need to worry about platform compatibility** - the SDK handles this automatically through the Docker-based packaging process.

## py-files directory

Your Python dependencies can be packaged as .py files, .zip archives (containing multiple .py files or a Python package structure), or .egg files.

```
.
├── payload
│ ├── config.json
│ ├── entrypoint.py
├── py-files
│ ├── moduleA
│ │ ├── __init__.py
│ │ ├── moduleA.py
```

## API

Your entry point script will define logic using the `Client` object which wraps data access layers.
Expand Down
13 changes: 12 additions & 1 deletion src/datacustomcode/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import importlib
from pathlib import Path
import runpy
import sys
from typing import List, Union

from datacustomcode.config import config
Expand All @@ -31,8 +33,9 @@ def run_entrypoint(
entrypoint: The entrypoint script to run.
config_file: The config file to use.
dependencies: The dependencies to import.
profile: The profile to use.
profile: The credentials profile to use.
"""
add_py_folder(entrypoint)
if profile != "default":
if config.reader_config and hasattr(config.reader_config, "options"):
config.reader_config.options["credentials_profile"] = profile
Expand All @@ -55,3 +58,11 @@ def run_entrypoint(
except (ModuleNotFoundError, AttributeError) as inner_exc:
raise inner_exc from exc
runpy.run_path(entrypoint, init_globals=globals(), run_name="__main__")


def add_py_folder(entrypoint: str):
default_py_folder = "py-files" # Hardcoded folder name
cwd = Path.cwd().joinpath(entrypoint)
py_folder = cwd.parent.joinpath(default_py_folder)

sys.path.append(str(py_folder))