Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Allowing magic functions to be used in functions imported from other scripts #334

Open
omeroguz45 opened this issue May 26, 2022 · 1 comment
Labels
feature request New feature or request

Comments

@omeroguz45
Copy link
Contributor

Context
Currently, when we are using magic functions (i.e. source() and write_to_source()) we have to use them in the same script that fal is being told to run. If you use them inside a custom function and try to use those functions in another script, even though you add the paths for both of the scripts in the schema, it fails.

Is your feature request related to a problem? Please describe.
When you have a big fal+dbt project, you have multiple scripts. These scripts often have the same repeated uses of the magic functions which can be made into functions and stored in another script. The scripts then can just import the necessary functions, adding to better code readability.

Describe the solution you'd like
An ability to import functions from other scripts that use magic functions. The scripts housing the functions can be stored in a utils dir inside fal_scripts. The path of the scripts can be added to the fal scripts section in the schema for fal to recognise.

@omeroguz45 omeroguz45 added the feature request New feature or request label May 26, 2022
@chamini2
Copy link
Member

chamini2 commented May 30, 2022

An easy way to support this would be by following dbt's Python model design which is based on functions that receive a "dbt" object.

def script(faldbt):
  faldbt.ref(...)

instead of the current

ref(...)

Also considered in #328


Also, we could just offer an object to pass those methods with, still running top-level code:

faldbt.ref(...)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants