pip_requirements
pip_requirements()
Allows specifying requirements to install in Layer backend when running decorated function.
Only one of file or packages can be defined. These settings will override requirements set via layer.init()
.
The decorator should only be used alongside Layer dataset
or model
decorators. It will only have effect on the remote execution of your decorated functions. If you require specific packages and you want to run the decorated function locally, you will need to install those requirements locally yourself.
Parameters
- file (Optional[str**]) -- Path to file listing requirements to install.
- packages (Optional[List[str]]) -- List of packages (and optionally their version) to install in Layer backend when running decorated function.
Returns
Function object.
Return type
Callable[[...], Any]
from layer.decorators import dataset, pip_requirements
layer.init("your-project-name", pip_packages=["tensorflow"])
# You can specify libraries to install via pip_requirements. Doing so will override
# requirements specified via layer.init above when running `create_product_dataset`
@pip_requirements(packages=["pandas==1.4.1"])
@dataset("product-data")
def create_product_dataset():
data = [[1, "product1", 15], [2, "product2", 20], [3, "product3", 10]]
dataframe = pd.DataFrame(data, columns=["Id", "Product", "Price"])
return dataframe