Believe it or not, but I had explained my problem to ChatGPT,
and that was also the suggestion it gave me!
Haha, cool!
os.chmod(f, stat.S_IEXEC | stat.S_IREAD | stat.S_IWRITE)
You can also write it in the following way (set +x
on top of the current permissions):
os.chmod(ipopt_path, os.stat(ipopt_path).st_mode | stat.S_IEXEC)
…but it would be easier to use Python magics, Terminal or init.sh
script for all the required pre-configuration – please see below for more details.
But is that the right or the best way to proceed?
Can I assume that the IPOPT binarie will remain there forever?
Data in the notebook_files
(and workspace_files
) folders is persisted between runs – these folders are located on a separate WebDAV storage and are mounted to a computational agent each time you start a notebook (“Attached data” → “Notebook files” in the side panel). Other files on the computation agent will be lost once the notebook is stopped (VM is disposed).
Do I still need to care about how to install this binary, or can I forget this story?
Do I need to include the installation code into my workbook?
While data in these folders is persisted, you will still need to set correct permissions each time the folder is mounted to the agent FS, but instead of this installation script you can always use console (“Tools” → “Terminal”) or Python magics (e.g. !sudo chmod +x ./ipopt
) to make any necessary changes.
Another option I’d recommend going with – is to create init.sh
file in the notebook_files
folder and place the following commands there to automate the process (this shell script is executed each time the computation agent is started):
sudo chmod +x /data/notebook_files/ipopt
sudo cp /data/notebook_files/ipopt /usr/local/bin/ipopt
Second command will add ipopt
binary to the PATH to make it available by its name from the terminal or Python magics (e.g. !ipopt
instead of !./ipopt
or !/data/notebook_files/ipopt
).
You can also move the binary and the init.sh
script to the Workspace Files folder (and update path to /data/workspace_files/*
) – this way it will be accessible from every notebook within a workspace (in “Home” workspace you will need to explicitly mount Workspace Files folder in each notebook, in other workspaces – workspace_files
folder is always attached to all notebooks).
Especially if I would share it at some time?
Attached files including the init.sh
script are available to all invited users.
Are there some examples showing how such things should be done?
Are there some guidelines?
Please refer to the documentation for more details:
There is also the following explanation when you create a new init.sh
file using the corresponding link from the Environment tab:
# This shell script runs when the machine starts,
# before the user-installed packages are set up.
#
# Use it to install additional dependencies.
#
# Examples:
#
# sudo apt update && sudo apt install -y some-package
#
# pip install some-package --additional-arguments
#
# The logs are stored in /tmp/log;
# the error log is copied to Notebook files.
Another question, maybe for another thread is about installing packages (pyomo).
Should I re-install pyomo everytime I start a session?
Or is there a way to ‘install’ it permanently?
I think my comments above cover those questions as well, but feel free to ask additional questions if you have any.
Thank you,
Igor