# Tracking .py file created in repository

**URL:** <https://renku.discourse.group/t/tracking-py-file-created-in-repository/231>\
**Category:** General\
**Created:** [4 January 2021 21:57 UTC](https://renku.discourse.group/t/tracking-py-file-created-in-repository/231 "2021-01-04T21:57:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kriegelw](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/kriegelw/32/130_2.png) [@Kriegelw](https://renku.discourse.group/u/Kriegelw)\
**Post date:** [4 January 2021 21:57 UTC](https://renku.discourse.group/t/tracking-py-file-created-in-repository/231/1 "2021-01-04T21:57:57Z")

</div>

I am currently working in a repository where I create a .py file with equations from a dataset, and tracking it to that point works.  
I then import the equations from this .py file in another notebook, where I use it in combination with another dataset to create a graphical output. When looking at the workflow, the dataset input is there but the .py is not.  
Is there a way to track importing internal .py files like this?

---

<div class="post-metadata">

**Author:** ![mohammad-sdsc](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/mohammad-sdsc/32/79_2.png) [@mohammad-sdsc](https://renku.discourse.group/u/mohammad-sdsc)\
**Post date:** [5 January 2021 08:58 UTC](https://renku.discourse.group/t/tracking-py-file-created-in-repository/231/2 "2021-01-05T08:58:34Z")

</div>

Hi @ Kriegelw,

You can define those files as explicit inputs to your command and renku will mark them as dependencies: `renku run --input path/to/equation-file.py ...`. See [https://renku-python.readthedocs.io/en/stable/commands.html#detecting-input-paths](https://renku-python.readthedocs.io/en/stable/commands.html#detecting-input-paths) for more details.

It’s also possible to define those explicit inputs in your script using renku API: [https://renku-python.readthedocs.io/en/stable/api.html](https://renku-python.readthedocs.io/en/stable/api.html). If you are not sure what approach to chose, then use command line argument for the moment since it does not require modifying your scripts.

Kind regards,  
Mohammad

---

<div class="post-metadata">

**Author:** ![schymans](https://yyz2.discourse-cdn.com/free1/user_avatar/renku.discourse.group/schymans/32/77_2.png) [@schymans](https://renku.discourse.group/u/schymans)\
**Post date:** [6 January 2021 13:39 UTC](https://renku.discourse.group/t/tracking-py-file-created-in-repository/231/3 "2021-01-06T13:39:55Z")

</div>

Hi @kriegelw,  
You could use papermill, e.g.:

```auto
renku run papermill notebooks/notebook.ipynb \
notebooks/notebook.ran.ipynb -p importfile definition.py

```

whereas notebook.ipynb uses the following code to import definition.py:

```python
with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    mod = importlib.import_module(basepath+importfile[:-3])
names = getattr(mod, ' __all__', [n for n in dir(mod) if not n.startswith('_')])
g = globals()
for name in names:
    g[name] = getattr(mod, name)

```
