-
Notifications
You must be signed in to change notification settings - Fork 40
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
switch to relative path #231
Conversation
Just checking, we don't have any code that assumes the current directory (so |
Could we end the command with |
@danielolsen nice, I didn't know that one. |
When you execute a command on the server using
In the first command, I change directory and list it. In the second command I list the current directory, which happen to be my home. |
powersimdata/scenario/execute.py
Outdated
command = "ln -s %s %s" % ( | ||
posixpath.join(const.BASE_PROFILE_DIR, source), | ||
posixpath.join(self.TMP_DIR, target), | ||
command = "cd %s; ln -s %s %s" % ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we cd
instead of doing posixpath.join(self.TMP_DIR, target)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure how we could get a link with a relative path if we don't first move into self.TMP_DIR
and pointing to the source from there. Maybe I don't understand the question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of relative path symlinks is that they are like a string, and are only resolved when they are accessed (i.e. after they are created). So we should be able to write that string to the target folder no matter where we call ln
from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Purpose
Use relative path in place of absolute path when creating a symbolic link to a base profile in the temporary folder of a scenario. That way, the link won'th break if we change the root of the file system (e.g.
/home/EGM/v2
is renamed/home/BES
) or when we move a scenario to a backup disk.What is the code doing?
There is no code.
Where to look
In the
_create_link_to_base_profile
method of theSimulation Input
class. I use thecd
command to move into the temporary folder of the scenario and then create a symbolic link to the base profile using a relative path.Time estimate
2min. This can be tested on creating, running, extracting a dummy scenario and then moving it to RE-Storage.