Run a notebook from another notebook in a Repo Databricks - databricks

I have a notebook with functions in a repo folder that I am trying to run in another notebook.
Normally I can run it as such: %run /Users/name/project/file_name
So I cloned the two files (function_notebook, processed_notebook) into a Repo in Databricks.
When I try to copy the path where I just cloned it, onlt this option appears: Copy File Path relative to Root
However in the Workspace user folder the option is Copy File Path
Evidently I dont quite grasp the difference between the relative path and the workspace path.
How can I run the notebook that has been cloned in the repo ?
Hierarchy:
RepoName (has 2 folders):
Folder1 Notebook1
Folder2 Notebook2
I'm in Notebook1 wanting to run Notebook2
%run ../Folder2/Notebook2

It's an UI problem that was already reported to development team. Until that time you need to create the path yourself. The difference is that it's starts with /Repos not with /Users. I have a small demo that shows how to use Repos to perform testing, etc. - if you interested in details.
But if the files are inside the same repository, then you don't need to use full paths, it's making them less portable - you can use relative paths, like, ./file_name to include notebook in the current folder, or ../file_name to include file in the level up folder, or ./folder/file_name to include file from the subfolder - but don’t specify file extension. In this case your code is portable, and could be used in different checkouts.
Example:
Notebook2:
Notebook1:
The name difference between workspace path & relative path is that former gives you full path inside the Workspace, while later gives you path relative to the root of the Repo

My notebook is called "UserLibraries" and i successfully ran it in separate cell without any other commands. Maybe it is the case. And if the path is correct I can open called NB in a new browser window by clicking path (it becomes hyperlink) (see picture).

Related

How to set RubyMine's default working directory to the executing .rb program's subdirectory?

In RubyMine, I have a project with many subfolders, each of which contains:
One or more standalone single-file executable Ruby programs (.rb files);
An input text file.
In older versions of RubyMine, when running one of the standalone executable programs (via Cmd+Shift+R on my Mac), the default folder in which RubyMine would look for the input file would be the same directory as the .rb file currently being executed -- which worked great.
The code used to read the file is something like:
data = File.readlines('input.txt')
However, after recently updating RubyMine to v2022.3.1, the behavior has changed, such that RubyMines now seems to be looking in the project's root directory for the file, instead of the same subdirectory as the .rb file currently being run. This produces the error:
in `readlines': No such file or directory # rb_sysopen - input.txt (Errno::ENOENT)
To correct this, I've been going into Run (menu) > Edit Configurations; and in the Edit Configurations dialog, in the configuration that RubyMine auto-created for the current executable file, changing the Working Directory value from the default of the project's root directory, to the subfolder of the current .rb file.
However, this above workaround is annoying, since I need to do it once each for every individual one of the many individual .rb executable files in my project.
My question: How can I configure my project and/or RubyMine itself to go back to the older behavior of defaulting a given .rb file to use its own directory as the default Working Directory, instead of the project's root directory?
(This question and/or its solution might also apply to other JetBrains IDEs such as IntelliJ, since they all seem to work similarly.)
The previous behaviour has been changed with https://youtrack.jetbrains.com/issue/RUBY-29236. So now yes, the logic is the following:
in case of no Ruby module, project's root will be used
in case of Rails, its home folder
otherwise the module's root
There is no option to change it in RubyMine but you can configure the configuration template using some variable there as Working directory.

mlflow run git-uri clone to specific directory

I am using mlflow run with a GitHub uri.
When I run using the below command
mlflow run <git-uri>
The command sets up a conda environment and then clones the Git repo into a temp directory, But I need it setup in a specific directory
I checked the entire document, but I can't find it. Is there no such option to do so in one shot?
For non-local URIs, MLflow uses the Python's tempfile.mkdtemp function (source code), that creates the temporary directory. You may have some control over it by setting the TMPDIR environment variable as described in Python docs (it lists TMP & TEMP as well, but they didn't work for me on MacOS) - but it will set only "base path" for temporary directories and files, the directory/file names are still will be random.

Moving Git to another folder, but I've got a problem

My git was init in folder ~/ryan/pythonproject/ and then later on I started using PyCharm and it created a venv for the project after importing. So now I have:
~/ryan/pythonproject/venv/
The first directory has my original work on the project, and then it appears I have a duplicate of my work under the venv folder.
Whenever I commit/add/push it does the original folder as well as the venv folder.
What I would like to do is have Git stop monitoring the original folder and only have git under the venv folder only. What's the best way to do that?
If you want to stop monitoring a folder you can put it to the .gitignore file. So i.e. you have:
YourProject/venv/FolderA
YourProject/venv/FolderB
YourProject/FolderA
YourProject/FolderB
Then just add the lower two to the .gitignore .
But please think about it whether this is really what you want. Usually it is the other way around. Keep your files and ignore the build folder.

How do i formulate file path for testsettings on the Runsettings file parameter <SettingsFile>

Whats the proper way to form relative file path/ or file path for the runsettings parameter
<SettingsFile>xxxxxAutomation.testsettings</SettingsFile>
In my local environment this works but when i push it to build release agents it fails since
its looking for the file in a different directory which is my release folder
but instead its looking for this file in what appears to be in a folder directory.
This is the directory its looking at E:\Agent_work\r10\a\xxxxxxxxx.testsettings,
here is my current way i have it set
<SettingsFile>xxxxxAutomation.testsettings</SettingsFile>
here is the error message
Error: The test settings file E:\Agent_work\r10\a\xxxxxxxxxx.testsettings, specified in the MSTestAdapter settings, is not available. Either access to the file is denied or the file does not exist. Ensure that the test settings file is available and try again.
instead of
E:\Agent_work\r10\a_XXXXX CI Build\drop\XXXXX_Automation_Test\bin\Release\xxxxxxxxx.testsettings
There is no documentation that states how to formulate the file path on msdn and didn't see
anything online.
I suggest you can add a Copy Files task to copy the missing file from .../bin/release folder(Use the browse option) to default working directory:
I suggest you resolve this issue via modifying your pipeline instead of settings file, so that you can also work well locally with the unchanged runsettings file.
In addition: Clean Target Folder input should be disabled(unchecked) cause our target folder is the default working folder. Deleting all files in that folder would cause unexpected issues.

Can I include a folder relative to the current directory in PATH in Powershell?

I run a lot of node projects and often have binaries located in:
.\node_modules\.bin
...relative to the projects folder. I'd like to be able to have PATH always include these directories, if they exist. I don't want to include other directories, just the one relative to the current directory. I'm familiar with
Add-PathVariable from PSCX and other Powershell basics, but how do I include a folder relative to the current dir in PATH?
Edit: as mentioned in the question, already, I expect the path to stay updated as the directory changes. This is not simply asking about how to use pwd.
You can use a relative path in Env:PATH and the binaries found will update dynamically:
Eg:
$env:PATH += ';.\node_modules\.bin'
Or with the PowerShell Community Extensions (PSCX):
Add-PathVariable '.\node_modules\.bin'
Unlike using $(pwd) the . is not immediately resolved to an absolute path, so PATH is always relative to the current working directory.
Testing this:
$ which uuid
C:\Users\username\Documents\myapp\node_modules\.bin\uuid.cmd
Then changing directory, uuid now refers to a program in a different dir:
$ cd ..\blog\
$ which uuid
C:\Users\username\Documents\blog\node_modules\.bin\uuid.cmd
It's also possible to persistently change PATH in the user or system environment:
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'User')
or
[Environment]::SetEnvironmentVariable(($env:PATH + ';.'), 'Machine')
Security note: when entering a command Windows will automatically search all directories in $env:PATH for files with one of the extensions listed in $env:PATHEXT and execute the first match it finds. Depending on where exactly in the search path you placed . that may even supersede system executables.
You may want to take a look at how to use package installed locally in node_modules for alternative approaches.

Resources