Skip to content

Commit 903633b

Browse files
authored
Merge pull request #41 from forcedotcom/py-files
@W-19315480 Py files locally
2 parents 00e3f66 + 9189da1 commit 903633b

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,21 @@ The SDK automatically handles all dependency packaging for Data Cloud deployment
104104

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

107+
## py-files directory
108+
109+
Your Python dependencies can be packaged as .py files, .zip archives (containing multiple .py files or a Python package structure), or .egg files.
110+
111+
```
112+
.
113+
├── payload
114+
│ ├── config.json
115+
│ ├── entrypoint.py
116+
├── py-files
117+
│ ├── moduleA
118+
│ │ ├── __init__.py
119+
│ │ ├── moduleA.py
120+
```
121+
107122
## API
108123

109124
Your entry point script will define logic using the `Client` object which wraps data access layers.

src/datacustomcode/run.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
import importlib
16+
from pathlib import Path
1617
import runpy
18+
import sys
1719
from typing import List, Union
1820

1921
from datacustomcode.config import config
@@ -31,8 +33,9 @@ def run_entrypoint(
3133
entrypoint: The entrypoint script to run.
3234
config_file: The config file to use.
3335
dependencies: The dependencies to import.
34-
profile: The profile to use.
36+
profile: The credentials profile to use.
3537
"""
38+
add_py_folder(entrypoint)
3639
if profile != "default":
3740
if config.reader_config and hasattr(config.reader_config, "options"):
3841
config.reader_config.options["credentials_profile"] = profile
@@ -55,3 +58,11 @@ def run_entrypoint(
5558
except (ModuleNotFoundError, AttributeError) as inner_exc:
5659
raise inner_exc from exc
5760
runpy.run_path(entrypoint, init_globals=globals(), run_name="__main__")
61+
62+
63+
def add_py_folder(entrypoint: str):
64+
default_py_folder = "py-files" # Hardcoded folder name
65+
cwd = Path.cwd().joinpath(entrypoint)
66+
py_folder = cwd.parent.joinpath(default_py_folder)
67+
68+
sys.path.append(str(py_folder))

0 commit comments

Comments
 (0)