Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Configurable working directory #36

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ First, load the extension to enable the magic commands:
%load_ext nvcc4jupyter
```

To set a working dirctory other than the default one:
```
%config NVCCPlugin.wd = './newWorkingDir'
%reload_ext nvcc4jupyter
```

Running a quick CUDA Hello World program:
```c++
%%cuda
Expand Down
13 changes: 12 additions & 1 deletion nvcc4jupyter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from IPython.core.interactiveshell import InteractiveShell
from IPython.core.magic import Magics, cell_magic, line_magic, magics_class

from traitlets import Unicode

from .parsers import (
Profiler,
get_parser_cuda,
Expand All @@ -39,7 +41,16 @@ def print_out(out: str):
class NVCCPlugin(Magics):
"""
CUDA C++ plugin for Jupyter Notebook

Attributes
----------
``wd`` :string =tempfile.mkdtemp()
Configurable working directory.
"""

wd = Unicode(
tempfile.mkdtemp(), help="Configurable default working directory."
).tag(config=True)

def __init__(self, shell: InteractiveShell):
super().__init__(shell)
Expand All @@ -50,7 +61,7 @@ def __init__(self, shell: InteractiveShell):
self.parser_cuda_group_delete = get_parser_cuda_group_delete()
self.parser_cuda_group_run = get_parser_cuda_group_run()

self.workdir = tempfile.mkdtemp()
self.workdir = self.wd
print(f'Source files will be saved in "{self.workdir}".')

self.profiler_paths: Dict[Profiler, Optional[str]] = {
Expand Down
1 change: 0 additions & 1 deletion nvcc4jupyter/setup_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
PATH_PRIORITY_DIR = "/usr/bin/priority"
KAGGLE_GCC_8_PATH = "/usr/bin/gcc-8"


def print_platform(platform: str) -> None:
print(f'Detected platform "{platform}". Running its setup...')

Expand Down
Loading