Stata license format using dxjupyter notebook

Hello,

 

I would like to try using my Stata 18 license on dxjupyter notebook before using RStudio. 

Is the license json file correct below or does it look different?

{
 "license": {
   "key": "123456789012345678901234",
   "serial_number": "123456789012",
   "code": "1234-5678-9012",
   "authorization": "12345678"
 }
}
 

In addition, I found the information below on how to run it on python. Please let me know if this is correct assuming I have my do file. If so, does this assume that the dataset in CSV format, license and do files are in the root directory of the project? Or does the script determine which folder it is accessing within the root directory? If any of the information above or below are wrong, please let me know how to correct it. In addition, if I want to use the app instead of the command line, is the json file the same or is it modified to include -org for example? A clear example for both cases would be greatly appreciated. 

***************************************

# Example: Setting up Stata in a Jupyter Notebook on UKB RAP
import os
import json

# Load the license file
with open('stata_license.json', 'r') as f:
   license_info = json.load(f)

# Set environment variables for Stata license
os.environ['STATA_LICENSE_KEY'] = license_info['license']['key']
os.environ['STATA_SERIAL_NUMBER'] = license_info['license']['serial_number']
os.environ['STATA_CODE'] = license_info['license']['code']
os.environ['STATA_AUTHORIZATION'] = license_info['license']['authorization']

# Run Stata commands using subprocess or another method
import subprocess

# Example command to run Stata
stata_command = "stata-mp -b do your_script.do"
subprocess.run(stata_command, shell=True)
 

****************************************

Thanks!

 

May

 

Comments

3 comments

  • Comment author
    Rachael W The helpers that keep the community running smoothly. UKB Community team Data Analyst

    Hi May, I think you need to include your dnanexus username and your organization in the json file too, see https://documentation.dnanexus.com/user/jupyter-notebooks/stata-in-dxjupyterlab 

    0
  • Comment author
    May A. Baydoun

    Thank you so much! This is much appreciated. I will give it another try  I just was wondering if the organization part is the work organization (e.g. NIH) or the wallet information? If the latter, should the json file include it with the org- or without it?

    Right now the json file that I am using looks like this:


     "license": {
       "serialNumber": "<xxxxxxxx>",
       "code": "<xxxx xxxx xxxx xxx xxxx xxxx>",
       "authorization": "< xxx>",
       "user": "<myusername>",
       "organization": "<org-ukb_wallet_xxxxx>"
     }
    }

    Should I be removing the org- in the last part?

    This is specifically to run it on the app and not interactively. 

    The extension of this text file is .json. It is originally a notepad file txt file. If this doesn't work, please let me know what else I should do to get the correct formatted json file. 

    Thank you for your help,

     

    May

     

     

     

    0
  • Comment author
    Rachael W The helpers that keep the community running smoothly. UKB Community team Data Analyst

    I think it needs to be the wallet info, and I would guess that it needs to include the org- part.   However, I don't have a Stata licence, so I can't check this for you.

    Please give it a try, and if it fails let us know what the error message is.

    When you start your JupyterLab, you might need to set the Feature as Stata,

    If the subprocess.run step can't find your script file, you might need to copy it from your main project storage into the JupyterLab Instance storage.  This can be done by opening a $_ terminal and using a dx download command, eg

    dx download your_script.do

    The jupyterlab storage will disappear when the jupyterlab closes, so be sure to copy any results back to main storage, using dx upload filename, or dx upload *.*

    For more on dx commands see https://documentation.dnanexus.com/user/helpstrings-of-sdk-command-line-utilities .

     

     

    0

Please sign in to leave a comment.