Rocket U2 | UniVerse & UniData

 View Only

 Python package management with multiple UniData accounts

  •   Python
  •   U2PY
Charles Sasaki-Skopp's profile image
Charles Sasaki-Skopp posted 11-18-2021 18:52
Our company uses 2 UniData accounts, one for production (/ud/PRODUCTION) and the other for testing new features (/ud/TEST). Is there a way to configure UniData's python implementation so that it gives preference to python packages based on what account a user is in? For example, I might have a production version of a python file ( with a callable function in it called 'dothistask'.  
def dothistask():
print('I did it')
return 'useful value'
and in a uniBasic program, I could access this function by running
VALUE = PyCallFunction('usefultool','dothistask')
This package is located in /ud/PRODUCTION/PP. But I want to add a feature or function to this package, but don't want to affect production implementation. So I add this python file to /ud/TEST/PP. Unfortunately, there doesn't seem to be a way to make each account prefer one directory over another when importing a function, so operations in the TEST account continue to favor the package version present in the production directory. My custom .pth file:
What's the best-practice way to keep these concerns separate? Separating our TEST account to its own  VM/server, while probably most ideal, isn't an option.
Mike Rajkowski's profile image
ROCKETEER Mike Rajkowski
As I stated in my other Comment on the more general question, I do not recommend doing development on the same system as production.

Yet for the example you describe, you can put a relative path in the .pth file.


This will be resolved based on the current working directory when you start UniData.

The problem is when you do a LOGTO, it will not reevaluate the relative path, and you will still be getting the code from the other account.

IMHO: This is not a good idea and should be avoided