
    5i)                       d dl mZmZmZmZ d dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZ ej,                  ej.                         ddlmZmZ d dlZd dlmZ d dlmZ d dlm Z m!Z!m"Z"m#Z# dd	l$m%Z%m&Z&m'Z' dd
l$m(Z) ddl*m+Z+ ddl,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5 ddl6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZImJZJmKZKmLZLmMZMmNZNmOZOmPZPmQZQmRZRmSZSmTZTmUZU ddlVmWZWmXZX ddlYmZZZm[Z[m\Z\m]Z]m^Z^m_Z_m`Z`maZambZbmcZc ddldmeZemfZfm#Z#mgZgmhZhmiZimjZj ddlkmlZlmmZmmnZnmoZompZp ddlqmrZrmsZs ddltmuZu ddlvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZmZmZmZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ 	 d dlmZ 	 d dlZ ejz                          dej|                  vri	 dZdej|                  v r@ej|                  d   j                  d      r ej|                  d   Zdej|                  d<   	 d dlZereej|                  d<   d#d$ddd%Zi Zg d&Zd'g d(d)g d(d*g d(d+g d(d,g d(d-g d(d.g d(d/g d(d0g d(d&	Zg d1Zg d2Zd3 Z G d4 d5      Zd6 Zd7 Z ej                         fd8Z ej                         fd9Zej                  d:d Zd;ej|                  v r"ej|                  d;   d<z   ej|                  d;<   nd=ej|                  d;<    G d> d?      Zd@ ZdA ZdB ZڐdzdCZdD ZdE ZdF ZdG ZdH ZdI ZdJ ZdK ZdL ZdM ZdN ZdO ZdP ZdQ ZdR ZdS ZdT ZdU ZdV ZdW ZdX ZdY ZdZ Zd[ Zd\ Zd] Zd^ Zd_ Zd` Zda Zdb Zdc Zdd Zde Zdf Zdg Zdh Z di Zdj Zdk Zdl Zdm Zdn Zdo Zdp Zdq Z	dr Z
ds Zdt Zdu Zdv Z e       Zdw Zdx Zdy Zdz Zd{ Zd| Zd} Zd~ Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d{dZ)d Z*d Z+d{dZ,d|dZ-d Z.d Z/d Z0d Z1d Z2d Z3d Z4d Z5d}dZ6d Z7d Z8d Z9d Z:d Z; G d dejx                        Z= G d dejx                        Z> G d dejx                        Z? G d dejx                        Z@ G d dejx                        ZA G d dejx                        ZB G d dej                        ZDd~dZEd ZFd ZG eD e       dej                  dej                  z   dz    ed      z   dz    ed      z   dz    ed      z   dz   ej                  e9gd      ZKeKj                  de@d d       eKj                  ej                  d¬ë      ZOdeO_P        eOj                  dddde9gȫ      ZReRj                  ddʬ˫       eRj                  ddͬ˫      ZSeRj                  dΐeTdϬЫ      ZUeRj                  dddӬԫ      ZVej                  xeS_W        xeU_W        eV_W        eRj                  ddddج٫       eRj                  dddܬݫ       eRj                  ddd       eRj                  dd ej                  e?       eRj                  d#eج        eEeRd       eOj                  dddde9gȫ      ZYeYj                  dd˫       eYj                  dΐeTdЫ       eYj                  dddӬԫ       eYj                  e٬        eEeYd       eOj                  dddd      ZZeZj                  e;        eEeZd       eOj                  dddde9gȫ      Z[e[j                  dddd       e[j                  e߬        eEe[d       eOj                  dd ed      dz   ej                  de9g      Z\e\j                  d ed d      dܬݫ       e\j                  d edd      dܬݫ       e\j                  e        eEe\d       eOj                  dddd      Z]e]j                  ddddج٫       e]j                  dڐd	dܬݫ       e]j                  d
ddܬݫ       e]j                  e        eEe]d       eOj                  dddd      Z^e^j                  dddܬݫ       e^j                  ed#        eEe^d       eOj                  dddde9gȫ      Z_e_j                  dd˫       e_j                  dddd       e_j                  dd g d!d"d#       e_j                  d$d%dؐd&'       e_j                  e        eEe_d       eOj                  d(d)d*d+e9gȫ      Z`e`j                  d,d-˫       e`j                  dd.dd       e`j                  e        eEe`d       eOj                  d/d0d0e7e8e9e:gd12      Zaeaj                  d3d4d5dܬݫ       eaj                         Zcecj                  d6d7d8d9dܬ٫       eaj                  d:d;dܬݫ       eaj                  d<d=dܬݫ       eaj                  d>d?dܬݫ       eaj                  d@dAddBC      Zd e       ed_e        eaj                  e        eEeadD       eOj                  dEdFdFe7e9gdG2      Zfefj                  d3d4d5dܬݫ       efj                  d6d7dHdܬݫ       efj                  d@dAddBC      Zg edIJ      eg_e        efj                  e        eEefdD       eOj                  dKdLdLdMe9gȫ      Zhehj                  e        eEehdD       eOj                  dNdOdPdQe9gȫ      Zieij                  ddRddC      Zj edd#S      ej_e        eij                  dTdU˫       eij                  dVg d!dWdXY       eij                  dZd[dܬݫ       eij                  ed#\        eEeidD       eOj                  d]d^d^d_e9gȫ      Zkekj                  d@dd`dab      Zl edIJ      el_e        ekj                  e        eEekdD       eOj                  dcddej                   ede      dfz    edgdhdij      z   dkz   dle9e;gm      Zmemj                  dndodpdqr      Zn e       en_e        emj                  ds edtdu      ˫       emj                  dvdwdd#x       emj                  e+        eEemdD       eOj                  dydzej                   ed{      d|e9e;gm      Zoeoj                  dnd}dpdqr      Zp e       ep_e        eoj                  ds ed~du      ˫       eoj                  dvddd#x       eoj                  e        eEeodD       eOj                  dddde9gȫ      Zqeqj                  ddddܬݫ       eqj                  ddd@dqr      Zr edIJ      er_e        eqj                  e        eEeqdD       eOj                  dddde9gȫ      Zsesj                  ddd@dqr      Zt edIJ      et_e        esj                  e        eEesdD       eOj                  dddde9e;gȫ      Zueuj                  ddd@dqr      Zv e       ev_e        euj                  ddddܬݫ       euj                  ddddܬݫ       euj                  e        eEeudD       eOj                  dd ed      dz    ed      z   dz    ed      z   ej                  e<e7e8e9gd      Zwewj                  dddܬݫ       ewj                  dddܬݫ       ewj                  dTddܬݫ       ewj                  d edd      dܬݫ       ewj                  dddeT edd             ewj                  d@ edd      ˫      Zx e       ex_e        ewj                  e        eEewd       eOj                  ddde>e:e9gd2      Zyeyj                  ddqd      Zz e       ez_e        eyj                  ddej                  ˫       eyj                  dd edd      d       eyj                  ddddܬݫ       eyj                  dddܬݫ       eyj                  ddddej                  j                         «       eyj                  dÐdĐdŬë       eyj                  dƐdǐddܐɫ       eyj                  ed#ʫ        eEeydˬ       eOj                  d̐d͐dΐde9gȫ      Z|e|j                  ddАdqd@ѫ      Z} edgӫ      e}_e        e|j                  dddԬ˫       e|j                  ddՐddܬݫ       e|j                  ddddܬݫ       e|j                  d3d4ddܬݫ       e|j                  ddddej                  j                         «       e|j                  dِddܬݫ       e|j                  dېdܐeFdݐޫ       e|j                  dߐdddܐɫ       e|j                  e        eEe|dˬ       eOj                  dddd      Z~e~j                  d@d˫      Z edgӫ      e_e        e~j                  dd˫       e~j                  dd˫       e~j                  e        eEe~dˬ       eOj                  ddde9g      Zej                  d@ddq      Z edgӫ      e_e        ej                  dߐdddܐɫ       ej                  e        eEedˬ       eOj                  ddde7e9gd2      Zej                  ddeTddd       ej                  d@d˫      Z edgӫ      e_e        ej                  e        eEedˬ       eOj                  ddd e~d      z   dz   d e9e:gȫ      Zej                  dd      Zej                  dd      Zej                  dd      Zej                  dddܬݫ       ej                  d	d
dܬݫ       ej                  ddd      Z e       e_e        ej                  dddddd       ej                  dej                  ddd       ej                  dddddd       ej                  dddddd       ej                  ddddBԫ       ej                  d#        ej                  d!dd"dܐd#       ej                  d$ej                  dؐd#       ej                  d#%       ej                  d&d'dܐd(       ej                  d)ej                  dؐd(        eddgӫ      ej                  d*d+d,ë      _e        ej                  d#-       ej                  d.d/dܐd0       ej                  d1d2dؐd3       ej                  d4ej                  dؐd0       ej                  ddՐd5dd#x       ej                  d3d6d7dd#x       ej                  d8dd9dd:d;<       ej                  d=d>d?dd@dA<       ej                  dB       ej                  dCej                  dܐdD       ej                  dEdFdؐdD       ej                  dG       ej                  dHej                  dܐdI       ej                  dJdKdؐdI       ej                  dL       ej                  dMej                  dܐdN       ej                  dOdPdؐdN       ej                  dQej                  ddRdS       ej                  dTej                  ddRdU       ej                  dVej                  ddRdU       ej                  dWej                  dؐdR       ej                  dX       ej                  dYej                  dܐdZ       ej                  d[d\ e~d]      z   d^z    e~d_      z   dBz   dؐdZ       ej                  d`       ej                  dadbdؐdc       ej                  dddedfdgdج٫       ej                  d#h       ej                  diej                  dܐdj       ej                  dkej                  dؐdj       ej                  dldm˫       ej                  dndo e~dp      z   dqz   ej                         ej                  drdsdtu       ej                  dv edwd      dܬݫ       ej                  dx edyd      dܬݫ       ej                  dz ed{d      d|ë       ej                  d} ed~d      dë       ej                  d edd      dë        edgӫ      ej                  d edd      dë      _e        ej                  d edd      dܐd       ej                  d edd      dë       ej                  d edd      dë       ej                  e        eEed       ddlmZ eOj                  ddej                   ed      d      Zej                  ddd       ej                  dd ed      dBԫ       ej                  di ed      dܐdj       ej                  d1 ed      dؐd3       ej                  dddgej                         ej                  e        eEe       eOj                  dddd      Zej                  eD      Zde_P         eEed       ej                  dddde9gȫ      Z ed      ej                  dd˫      _e        ej                  ddddq       ej                  e        eEeed       ej                  dddde9gȫ      Z ed      ej                  dd˫      _e        ej                  ddddq       ej                  e"        eEeed       ej                  dddeKe:e9eLgd2      Z edgӫ      ej                  dd˫      _e         e e        edgӫ      g      ej                  dd˫      _e        ej                  ddddd       ej                  dTd˫       ej                  ddd       ej                         Zej                  dÐdĬ˫       ej                  dŐdƬ˫       ej                  e)j(                          eEeed       ej                  dǐdȐdȐde:e9gȫ      Zej                  dʐdˬ˫       ej                  d̐dͬ˫       ej                  dVddΐdgdАѫ       ej                  dd#dܐdӐԫ       ej                  dddؐd֐dאث       ej                  dg dڢdXdېܫ       ej                  d$d#dܐdݐԫ       ej                  e[        eEeedސ       eOj                  dߐddd      Zej                  eD      Zde_P         eEed       ej                  dddde9gȫ      Z ed      ej                  dd˫      _e        ej                  e!        eEeed       ej                  dddde9gȫ      Z ed      ej                  dd˫      _e        ej                  e#        eEeed       ej                  ddde9gd2      Z edgӫ      ej                  dd˫      _e        ej                  e)j6                          eEeed       ej                  d ed      dz    ed      z   dz    ed      z    ed      d      Z eEee       ej                  eD      Zde_P        ej                  dd ed      e9gd2      Zej                  dd˫       ej                  dd`d       ej                  dd#ddܐ       ej                  dd#d dܐ       ej                  dސddeT       ej                  e%        eEeedː       eOj                  dddd      Zej                  eD      Zde_P         eEed       ej                  ddd	d
e9gȫ      Z ed      ej                  dd˫      _e        ej                  ddddq       ej                  e         eEeed       ej                  dddde9gȫ      Z ed      ej                  dd˫      _e        ej                  ddddq       ej                  e&        eEeed       ej                  ddde:e9gd2      Z edgӫ      ej                  dd˫      _e        ej                  dd˫       ej                  e)jH                          eEeed       ej                  dǐddde:e9gȫ      Zej                  dʐdˬ˫       ej                  d̐dͬ˫       ej                  dddؐddث       ej                  dddؐddث       ej                  dddedؐdfd       ej                  e\        eEeedސ       eOj                  dNddd       Zej                  eD      Zd!e_P         eEed       ej                  dސd"d"e:e9gd#2      Zej                  dʐdˬ˫       ej                  dTd$˫       ej                  d%d&g d'(       ej                  d)d*dΐdg(       ej                  d+d,˫       ej                  d-d.d/gd0       ej                  d#1      Zej                  d2dܐd3u       ej                  d4dܐd5u       ej                  d6d7d89       ej                  e_        eEeedސ       ej                  dd:d;e:e9gd<2      Z edgӫ      ej                  dd˫      _e        ej                         Zej                  d=d>˫       ej                  d?d@dܬݫ       ej                  dAdB˫       ej                  dCdD˫       ej                         Zej                  dÐdE˫       ej                  dFdGdܬݫ       ej                  e)jZ                          eEeed       ej                  ddHdHeKe:e9eLgdI2      Z edgӫ      ej                  dd˫      _e        ej                  ddJ˫        e e        edgӫ      g      ej                  dKdL˫      _e        ej                  dddddM       ej                  ddNdܬݫ       ej                         Zej                  dTd˫       ej                  dOdPdܬݫ       ej                         Zej                  dÐdĬ˫       ej                  dŐdƬ˫       ej                  e)jb                          eEeed       ej                  dǐdQdQdRe:e9gȫ      Zej                  dʐdˬ˫       ej                  d̐dͬ˫       ej                  dVdΐdgdS       ej                  dҐd.d/gdT       ej                  dUd.d/gdV       ej                  dg dڢdW       ej                  e]        eEeedސ       ej                  ddXddYe:e9gȫ      Zej                  dZd[˫       ej                  dTd\˫       ej                  dAd]˫       ej                  dCd^˫       ej                  d_d.d/gd`       ej                  dad.d/gdb       ej                  dcd.d/gdd       ej                  ded.d/gdf       ej                  dgd.gdh       ej                  did.d/gdj       ej                  dkd.d/gdl       ej                  d>dmen       ej                  dodpd.d/g(       ej                  dqdren       ej                         Zej                  dsdtedqu       ej                  dvdwdܬݫ       ej                         Zej                  dxdyeFn       ej                  dzd{dܬݫ       ej                  e        eEeed|       eOj                  d}d~d e~d      z   dz   de9gȫ      Zej                  dd˫      Z ed#      e_e        ej                  e'        eEed       eOj                  dddde9gȫ      Zej                  dd˫      Z ed      e_e        ej                  e(        eEed       eOj                  ddd# ed e~d      z   dz    e~d      z   dz         dz    ed e~d      z   dz         z   dz    ed e~d      z   dz         z   dpej                  eKe:e9eHeLeQeRg      Zej                  d edd      ddC      Z e e        eddgd      g      e_e        ej                  dd edd      dse       ej                  dddd e=       ej                  d edd      ˫       ej                  ddd edd             ej                  ddddI edd             ej                  dd edd      dܬ٫       ej                  dd edd      9       ej                  dd edd      ddsg        ej                  dd edd      ddsg        ej                  dT edd      ˫       ej                  d edd      dܬݫ       ej                  dg d edd             ej                  dd edd      u       ej                  dddedfddج٫       ej                  dddܬݫ       ej                  dddܬݫ       ej                  ddsdd edd             ej                  d edd      dܬݫ       ej                  dd edĐd      9       ej                  dŐdsg dƢ edǐd      ȫ       ej                         Zej                  d edʐd      dܬݫ       ej                  dːd̐d edΐd      dsϫ       ej                  dАd̐d edҐd      dsϫ       ej                  dӐdԐd ed֐d      ׫       dؐZej                  dِd edېj                  eܫ      d      dsݫ       ej                  d edߐd      e>d        ej                  d edd      dܬݫ       ej                  d edd      de       ej                  ddeTd edd             ej                  d edd      ˫       ej                  d edd      ˫       ej                  ddd edd             ej                         Zej                  dd edd      u       ej                  dd edd      9       ej                  e/d#d#dddd        eEed       eOj                  d3ddde9e7g      Zej                  dd˫       ej                  dddeTdޫ       ej                         ZÐeÐj                  d ddܬݫ       eÐj                  dddeT edd             ej                  d6ddsg d       ej                  dddܬݫ       ej                  dd	dܬݫ       ej                  d
ddܬݫ       ej                  dddؐd       ej                  dddܬݫ       ej                  dddؐd       ej                  ddddܬݫ       ej                  ddd˫       ej                  dddؐdd       ej                  d edd      g dd !        G d" d#ejx                        ZĐej                  d$ed d%       ej                  e1        eEed       eOj                  d&d'd(d)e9gȫ      ZŐeŐj                  d*d+ej                         eŐj                  d,d-dܬݫ       eŐj                  e3        eEeŐd       eOj                  d.d/d0d1e9gȫ      ZƐeƐj                  d2d3˫       eƐj                  d4d5ej                         eƐj                  ddÐdĐ9       eƐj                         Zǐeǐj                  d6d7dd#x       eǐj                  ddsdd ed8d             eƐj                  d9dej                  d:;       eƐj                  e6        eEeƐd       eOj                  d<d=d>d?e9gȫ      ZȐeȐj                  dd@dq       eȐj                  e0       eeɐd<<   eːdA   dB   j                  eOj                  dC   j                  eOj                  dC   j                  f       eːd   dB   j                  eOj                  dC   j                  eOj                  dC   j                  f       eOj                  dDdEdFdGe9gȫ      Z̐e̐j                  d֐dHddqr      Z eddS      e͐_e        e̐j                  dddedfddج٫       e̐j                  dddIdܬݫ       e̐j                  e        eEe̐dD       eOj                  dJdKdLdM      Zΐeΐj                  eD      ZϐdNeϐ_P         eEeΐdˬ       eϐj                  dOdPdPe:e9gdQ2      ZАeАj                  dR      Zѐeѐj                  dSdTddUV       eѐj                  dWddXV       eѐj                  dYdZ˫       eѐj                  d[d\˫       eѐj                  d]d^˫       eѐj                  d_d`˫       eѐj                  dadb˫       eѐj                  dcdd˫       eАj                  dedf      ZҐeҐj                  dgdˬ˫       eҐj                  dVdΐdgdϐeBdhi       eҐj                  djd#eBdkԫ       eҐj                  dd#eBdlԫ       eҐj                  ddeBd֐dmث       eҐj                  dg dڢdXeBdni       eҐj                  d$d#eBdoԫ       eАj                  e        eEeАeϐd       eϐj                  dސdpdqe:e9gdr2      ZӐeӐj                  dsdtd       eӐj                  duddvV       eӐj                  d%dΐdwg d'x       eӐj                  d)dΐdydΐdgx       eӐj                  e^        eEeӐeϐdސ       eϐj                  ddzdze:e9gd{2      ZԐeԐj                  dsd|d       eԐj                  drd}˫       eԐj                  d~dddܬݫ       eԐj                  d>d˫       eԐj                  ddd#dܐ       eԐj                  dkdd#dܐ       eԐj                  dxdyeFn       eԐj                  deFdЫ       eԐj                  deFdЫ       eԐj                  deGdЫ       eԐj                  dd˫       eԐj                  dd˫       eԐj                  e        eEeԐeϐdD       eϐj                  ddde>e?e:e9gej                  d      ZՐeՐj                  dd˫      Z֐eՐj                  dddܬݫ        edgӫ      e֐_e        eՐj                  e        eEeՐeϐdD       eϐj                  ddde>e?e:e9gej                  d      Zאeאj                  d=d>˫       eאj                  dAdB˫       eאj                  dCdD˫       eאj                  dÐdE˫       eאj                  d edd      ˫      Z edgӫ      e֐_e        eאj                  e)j                          eEeאeϐd       eOj                  dddde9gȫ      Z e       eِj                  d@d˫      _e        eِj                  e        eEeِd|       eOj                  dddde9e;gȫ      Z e       eڐj                  d@d˫      _e        eڐj                  ddd       eڐj                  ddd˫       eڐj                  e        eEeڐd|       eOj                  dddde9e;gȫ      Z e       eېj                  d@d˫      _e        eېj                  dddgd       eېj                  e        eEeېd|       eOj                  dddde9e;gȫ      Z e       eܐj                  d@d˫      _e        eܐj                  ddqdd       eܐj                  e        eEeܐd|       eOj                  dddde9e;gȫ      Z e       eݐj                  d@d˫      _e        eݐj                  ddqdd       eݐj                  e        eEeݐd|       eOj                  dddde9e;e=g      Z e       eސj                  d@d˫      _e        eސj                  ddqdd       eސj                  e        eEeސd|       eOj                  dÐdĐdŐde9e;e=g      Z e       eߐj                  d@d˫      _e        eߐj                  ddqddǐ       eߐj                  e        eEeߐd|       eOj                  dȐdɐdʐde9e;gȫ      Zej                  d@d̬˫      Z edͫ      e_e        ej                  dsdά˫       ej                  e        eEed|       eOj                  dϐdАdѐde9e;e=gȫ      Z e       ej                  d@d˫      _e        ej                  dӐdqdԐdՐ       ej                  e         eEed|       eOj                  d֐dאdؐde9e;e=gȫ      Zej                  d@d˫      Z e       e_e        ej                  dӐdqdڐdې       ej                  e        eEed|       eOj                  dܐdݐdސde9e;gȫ      Z e       ej                  d@ddq      _e        ej                  dddܬݫ       ej                  e        eEed       eOj                  dddde9gȫ      Zej                  d@ddq      Z e       e_e        ej                  dddܬݫ       ej                  e        eEed       eOj                  dddde9gȫ      Z eg dӫ      ej                  d@d˫      _e        ej                  ddd˫       ej                  dd`d       ej                  dd#ddܐd       ej                  dd#ddܐ       ej                  dddܬݫ       ej                  dddܬݫ       ej                  ddՐddܬݫ       ej                  e
        eEedˬ       eOj                  dddej                  d       Zej                  eD      Zde_P         eEed       ej                  d ed       ed      e:e<e8e9gd2      Zej                  dTd˫        eeu      ej                  dd˫      _e        ej                  dd	d eA       ej                  d3d4d
dܬݫ       ej                  dddܬݫ       ej                  dddܬݫ       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  e        eEeed       ej                  d ed       ed      e:e<e8e9gd2      Zej                  dTd ˫        eeu      ej                  dd!˫      _e        ej                  dd"d eA       ej                  d3d4d#dܬݫ       ej                  dd$dܬݫ       ej                  dd%˫       ej                  dd&˫       ej                  dd'˫       ej                  dd(˫       ej                  dd)˫       ej                  dd*˫       ej                  dd+˫       ej                  e        eEeed       ej                  d, ed-       ed.      eEe:e<e7e8e9eAgej                  d/d01      Z eFe       ej                  ed23        edJ      e_e         eEeed       ej                  d4 ed5       ed6      eEe:e<e7e8e9eAgej                  d/d71      Z eFe       ej                  ed83        edJ      e_e         eEeed       ej                  d9 ed:       ed;      eEe:e<e7e8e9eAgej                  d/d<1      Z eFe       ej                  ed3        edJ      e_e         eEeed       ej                  d ed=       ed>      e:e<e7e8e9eAgd?2      Zej                  d@dAg dBdCdDE       ej                  dFg dGdH       ej                  dIg dJddKܫ       ej                  dTdL˫       ej                  dMdNdOg dPx       ej                  dQdR˫       ej                  dSdT˫       ej                  dUdVdWdܬݫ       ej                  dej                  ˫        edIJ      ej                  dej                  ˫      _e         edIJ      ej                  ddXdYZ      _e        ej                  d[d\d]dج٫       ej                  dd^˫       ej                  dd_˫       ej                  dd`˫       ej                  dda˫       ej                  drdb˫       ej                  e        eEeed       ej                  d edc       edd      e:e<e8e9eAeSgde2      Zej                  dTdf˫       ej                  dVg d!dW       ej                  dZd[dܬݫ       ej                  ddg˫       ej                  ddh˫       ej                  drdb˫       ej                  did.d/gdi       ej                  e        eEeedː       ej                  d edj      dz    edk      z   dz    edl      z   dz    edm      z   dz    edn      z    edj      do      Z eEee       ej                  eD      Zde_P        ej                  dpdq edr      e:e<e8e9gds2      Zej                  dʐdt˫       ej                  dVdΐdgdu       ej                  ea        eEeedސ       ej                  d֐dv edw      e:e<e8e9eAeSgdx2      Zej                  dʐdt˫       ej                  dTdy˫       ej                  dzdqd{       ej                         Zej                  d|d}d~dd       ej                  dd}ddd       ej                  ddg˫       ej                  ddh˫       ej                  drdb˫       ej                  eb        eEeed       ej                  dd ed      e:e<e8e9gd2      Zej                  dʐdt˫       ej                  dTd˫        eeu      ej                  dd˫      _e        ej                  dd	d eA       ej                  d3d4d
dܬݫ       ej                  dddܬݫ       ej                  dddܬݫ       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  dd˫       ej                  ec        eEeed       ej                  d ed      de:e9e8e<gd2      Zej                  dVdΐdgdd       ej                         Zej                  ddܐdu       ej                  dddؐd'       ej                  e`d        eEeedސ       ddlmZ eOj                  dddej                  d       Zej                  ddg d(        edgӫ      ej                  ddg d      _e        ej                  dddd#x       ej                  dΐddԫ        edgӫ      ej                  dd˫      _e        ej                  dސddԫ       ej                  ddddؐd       ej                  dddԫ       ej                  dddԫ       ej                  dddܬݫ        ej                  ee5      Zej                  e        eEedd#       ddlmZ eOj                  dddej                  d       Z edgӫ      ej                  ddg ej                        _e        ej                  dΐddԫ       ej                  dސddԫ       ej                  ddddؐd       ej                  dddԫ       ej                  e        eEedd#       eOj                  ddej                   ed      dz   de9gm      Zej                  d edÐdĐ      ˫       ej                  d edƐdĐ      ˫       ej                  dǐddȐdɐb       ej                  d edːdĐ      ˫       ej                  e        eEe       eOj                  d̐d͐dΐdϬ      Zej                  dАd edѐd      dsݫ        edIJ      ej                  ddҐdYdӫ      _e        ej                  ddԐdՐd֬ԫ       ej                  e7        eEe       eOj                  d(dאdؐd٬      Z  eddgӫ      e j                  ddڬ˫      _e        e j                  dېddؐdݬ       e j                  e8        eEe        eOj                  dސdߐdj                   e~d       e~d       e~d            dz   ej                  e;gd      Zej                  ddddܬݫ       ej                  dd edd      dz    edd      z   d#dܐ       ej                  dddedf edd      ddؐ       ej                  dd\ edd      dج٫        e       ej                  d@ edd      g dq      _e        ej                  dd      Zej                  e9d        eEedD       eOj                  dddj                   e~d       e~d       e~d            dz   ej                  e;gd      Zej                  d edd      dz    edddi      z   dz    edddi      z   g d d!       ej                  ddddܬݫ       ej                  dddedf edd      ddؐ       ej                  dd\ edd      dج٫        e       ej                  d@ edd      g dq      _e        ej                  dd       ej                  e9d        eEedD       eOj                  dddd      Zej                  d@d	˫       ej                  d
ddd#d       ej                  dedЫ       ej                  dedЫ       ej                  ddd#d       ej                  dddddd       ej                  ddd˫       ej                  ddd#d       ej                  ddd#d       ej                  dd˫       ej                  e-        eEe       eOj                  dd d d!      Zej                  eD      ZdNe_P         eEe       ej                  d"d#d#$      Zej                  d@ed%Ы       ej                  d&dd'       ej                  d1      Zej                  d(dܐd)u       ej                  d*edddd+,       ej                  d-edddd.,       ej                  d/edddd0,       ej                  d#1      Z	e	j                  d1dܐd2u       e	j                  d3dܐd4u       ej                  d5ej                  dܬݫ       ej                  ddܐd6u       ej                  ddedd7       ej                  e.        eEe       ej                  d8d9d9$      Z
e
j                  d@ed%Ы       e
j                  d1      Zej                  d(dܐd:u       ej                  d;dܐd<u       ej                  d=edddd>,       ej                  d?dܐd@u       e
j                  dAdܐdBu       e
j                  dCeddD       e
j                  d&ddE       e
j                  d5ej                  dܬݫ       e
j                  ddܐd6u       e
j                  ddedd7       e
j                  e/        eEe
       ej                  dFdGdG$      Zej                  d@dedHI       ej                  d(dܐdJu       ej                  dKdܐdLu       ej                  d?dܐd@u       ej                  d&edMЫ       ej                  dNdOedPЫ       ej                  dQdedRЫ       ej                  d5dSdܬݫ       ej                  ddܐdTu       ej                  dCdqddUb       ej                  dVdWdܐdXu       ej                  dddY dZЫ       ej                  dded[Ы       ej                  e1        eEe       eOj                  d\d]d]d^e:gd#_      Zej                  dded`I       ej                  d*dedHa       ej                  d1      Zej                  dbedcЫ       ej                  ddedeЫ       ej                  dddfdgݫ       ej                  e0        eEe       dhj                  eD  cg c]  } | e|    di   z    c}       ZeOj                  dgdj edk      dlz   ez   dmz    edndio      z   dpz   ej                  dq       Zej                  dr edsd      ddC       ej                  dt edudv      ddC       ej                  e:       eeɐdg<   eeɐdw<   eD ];  Zeːe   dB   j                  dgeOj                  dC   j                  f       = eːdA   dB   j'                          dx Zedyk(  r	 e        yy#  d dlmZ Y bxY w#  Y bxY w# e$ rZd dlZY dZ[Đb^dZ[ww xY w# e$ r) ej                  d k7  r ed!ej                  "       Y bw xY wc c} w (      )print_functionunicode_literalsdivisionabsolute_importNlevel   )sys_encoding
basestring)dx_build_app)workflow_builder)PermissionDeniedInvalidStateResourceNotFound
DXCLIError)try_callprompt_for_ynINTERACTIVE_CLI)workflow)cp)extract_datasetextract_assay_germlineextract_assay_somaticcreate_cohortextract_assay_expression)download_one_filedownload_one_database_filedownload)no_color_arg	delim_argenv_argsstdout_argsall_argjson_argtry_argparser_dataobject_args$parser_single_dataobject_output_argsprocess_properties_args find_by_properties_and_tags_argsprocess_find_by_property_argsprocess_dataobject_args%process_single_dataobject_output_argsfind_executions_argsadd_find_executions_search_gpset_env_from_args
extra_argsprocess_extra_argsDXParserErrorexec_input_argsinstance_type_argprocess_instance_type_arg'process_instance_type_by_executable_argprocess_instance_count_argget_update_project_argsproperty_argstag_argscontains_phiprocess_phi_param(process_external_upload_restricted_param)ExecutableInputsformat_choices_or_suggestions)
get_org_invite_argsadd_membershipremove_membershipupdate_membershipnew_org
update_org	find_orgsorg_find_membersorg_find_projectsorg_find_apps)err_exitDXErrorr   
DXAPIErrornetwork_exceptionsdefault_expected_exceptionsformat_exception)warngroup_array_by_fieldnormalize_timedeltanormalize_time_inputmerge)	batch_runbatch_launch_args)APP_CATEGORIES)CYANBLUEYELLOWGREENREDWHITE	UNDERLINEBOLDENDCDNANEXUS_LOGO
DNANEXUS_X
set_colorsset_delimiterget_delimiter	DELIMITERfilltty_rowstty_colspagerformat_find_resultsnostderr)format_treeformat_table)clean_folder_pathpickpaginate_and_pick	is_hashidis_data_obj_idis_container_id	is_job_idis_analysis_idget_last_pos_of_charresolve_container_id_or_nameresolve_pathresolve_existing_pathget_app_from_pathresolve_appresolve_global_executableget_exec_handlersplit_unescapedResolutionErrorresolve_to_objects_or_projectis_project_explicitobject_exists_in_projectis_jbor_strparse_input_keyval)path_completerDXPathCompleterDXAppCompleterLocalCompleterListCompleterMultiCompleter)	print_data_obj_desc
print_descprint_ls_descget_ls_l_descprint_ls_l_headerprint_ls_l_descget_ls_l_desc_fieldsget_io_descget_find_executions_string)SystemRequirementsDict)urlparse_ARGCOMPLETETERMxtermvt100ntzBWarning: readline module is not available, tab completion disabledfileFauto)interactivecolors	delimitercurrentproj)	allsessionfsdatametadatar   execorgotherz		All commands)desccmdsz	Manage your login sessionz/		Navigate and organize your projects and filesz!		View, download, and upload dataz<	View and modify metadata for projects, data, and executionsz	View and modify workflowsz-		Manage and run apps, applets, and workflowsz 		Administer and operate on orgsz"		Miscellaneous advanced utilities)internetUsageIPsrunSystemRequirements!runSystemRequirementsByExecutable$mergedSystemRequirementsByExecutablejobLogsForwardingStatusinstanceTypeTransitions)r   r   r   runStageSystemRequirementsr   c                     t        |      rt        }nt        |      rt        }n| S | j	                         D ci c]  \  }}||vs|| c}}S c c}}w )a/  
    Filter out verbose-only fields from a job or analysis description.

    Args:
        description (dict): The entity description to filter
        entity_id (str): The entity ID to determine if it's a job or analysis

    Returns:
        dict: Filtered description without verbose-only fields
    )ru   VERBOSE_ONLY_JOB_FIELDSrv   VERBOSE_ONLY_ANALYSIS_FIELDSitems)description	entity_idverbose_fieldskvs        q/home/marpiech/ifpan-abm-pgxpred/analysis/marpiech-gwas-test/venv/lib/python3.12/site-packages/dxpy/scripts/dx.pyfilter_verbose_fieldsr      sP     0			"5(..0LTQA^4KAqDLLLs   AAc                       e Zd Zd Zd Zy)ResultCounterc                     d| _         y Nr   )counterselfs    r   __init__zResultCounter.__init__   s	        c                     | xj                   dz  c_         | j                   dkD  rdndt               z   dz   t        | j                         z   dz   t               z   S )N   
 zResult :)r   r^   strr`   r   s    r   __call__zResultCounter.__call__   sT    q(bIK?)K #$&*f- 	-r   N)__name__
__module____qualname__r   r    r   r   r   r      s    -r   r   c                  :    t        | dt        j                  i| y )Nr   )printsysstderr)argskwargss     r   eprintr      s    	4+cjj+F+r   c                  |    t        d      } d }	 t        j                  |       }|S # t        $ r t	        d      w xY w)NzType JSON here> z-Error: user input could not be parsed as JSON)inputjsonloads
ValueErrorr   )user_json_str	user_jsons     r   get_json_from_stdinr      sM    ,-MIJJJ}-	   JHIIJs   & ;c                     d| v r| j                   t        d<   t        d   dk(  r(t        t        j                  j                                y t        t        d   dk(         y )Ncolorr   r   on)r   staterc   r   stdoutisattyr   s    r   set_cli_colorsr      sH    $**hX& 3::$$&'5?d*+r   c                 j    d| v r| j                   t        d<   n	d t        d<   t        t        d          y )Nr   )r   r   rd   r   s    r   	set_delimr      s/    d!^^k!k%$%r   r   LESSz -RSz-RSc                   h    e Zd Zg dg dg dg dg dddgdZ edg      Zd	 Zd
 Zd ZddZ	d Z
y)DXCLICompleter)zdata 	projects zapps zjobs zexecutions z	analyses zorgs org )zrecord project 	workflow r   zuser )zdevelopers zusers stage member )r   r   r   r   r   r   zmembers )findnewaddremoveupdater   exportc                     t        t        j                  j                               D cg c]  }|| j                  vs|dz    c}| _        g | _        d | _        y c c}w N )list
subparserschoiceskeyssilent_commandscommandsmatchestext)r   subcmds     r   r   zDXCLICompleter.__init__   sO    489K9K9P9P9R4Sz&W]eieyeyWy#z	 {s
   AAc                 p    | j                   D cg c]  }|j                  |      s| c}| _        y c c}w N)r  
startswithr  )r   prefixcmds      r   get_command_matchesz"DXCLICompleter.get_command_matches   s&    '+}}Ov8NOOs   33c                     || j                   v r;| j                   |   D cg c]  }|j                  |      s|dz   |z    c}| _        y y c c}w r   )subcommandsr	  r  )r   commandr
  subs       r   get_subcommand_matchesz%DXCLICompleter.get_subcommand_matches   sM    d&&&;?;K;KG;ToCX[XfXfgmXnGcMC/oDL 'os
   A
Ac           	         || _         t        d|      }t        d|      }t        |      dkD  r"|t        |      dz
  k(  r|j	                  d       t        |      }g | _        |dk(  r| j                  d       | j
                  S |dk(  r | j                  |d          | j
                  S |dk(  r5|d   | j                  v r$| j                  |d   |d          | j
                  S |d   dk(  rt        |d   dd	gd
      }n|d   dv rt        |d   d      }nx|d   dv rt        |d   dg      }n_|d   dv rt        |d         }nI|d   dv rt        |d         }n3|d   dv rt        |d   d      }n|d   dv rt        |d   dd      }ng }|r|D cg c]  }|d |dz    |z    c}| _        n|| _        |d   dv r	 t        t        j                  ddddi            }|d   dv r|D 	cg c]  }	|	d   d    r|	 }
}	n|D 	cg c]  }	|	d   d    s|	 }
}	|
D 	cg c]
  }	|	d   d!    }}	|D cg c]  }|j                  |d         s| }}|r8| xj
                  |D cg c]  }|d |dz    |z    c}z  c_        | j
                  S | xj
                  |z  c_        	 | j
                  S | j
                  S c c}w c c}	w c c}	w c c}	w c c}w c c}w #  Y | j
                  S xY w)"Nr   r   r   r   r	   runappletr   visibleclasses
visibility)cdrmdirmkdirtreefolderexpected)headcatr   r   r  )lsrmmvr   )get_detailsset_detailsset_visibility	add_typesremove_typescloseget)describerenameset_propertiesunset_propertiesTinclude_current_proj)	rmprojectinviteprojectr   r3  )r  install	uninstallfields)name	installed)r.  )r  r9  r.  r<  r;  )r  rw   r   lenappendr  r  r  r  r   r   dxpy	find_appsr	  )r   r  want_prefix	space_poswords	num_wordspath_matchesmatchinitial_resultsresultfiltered_results	app_namesr;  app_matchess                 r   get_matcheszDXCLICompleter.get_matches   sr   	(d3	T*u:>i3t9q=8LLJ	>$$R(j ||i !^$$U1X.f ||e !^aD,<,< <''a%(;b ||_ Qx5 -eBi7?6L9B D q==-eBi7? Aq88-eBi7=h @q55-eBi8qzz-eBi8qYY-eBidSq44-eBi)bfg!JVW^i!m 4u <W+ Qx::&*4>>HW[\`Ob Dc ,d 'eOQx#77AP ,Mv,2:,>{,K -3 ,M( ,M BQ ,Qv06z0B;0O -3 ,Q( ,QJZ [
!3F!; [I [4="\DQVWYQZA[4"\K"\"S^(_%ny1})=)E(__ ||	 3 ||t||3  X,M,Q ["\(_||s`   J:?/K .J??K KK K	,K 2KKK $K6
K K ?K K'c                     |dk(  r| j                  |d       |t        | j                        k  r| j                  |   S y )Nr   T)rA  )rL  r=  r  )r   r  r   s      r   completezDXCLICompleter.complete1  s?    A:Tt43t||$$<<&&r   NF)r   r   r   r  setr  r   r  r  rL  rN  r   r   r   r   r      sI    pOHKS&
35K 8*oO
Pp>@r   r   c           	         t         d   sd| _        d}d}| j                  r$| j                  s| j                  | _        d | _        | j                  | j                  d u | j
                  d u k7  rt        dd       t        j                  | j                  | j
                  | j                        |k(  }fd}d?d}t        d	z          d
\  }}}|dk  r,	  |||      } |d@dt        | j                  dd      i|}		 t+        j,                  	d   |	d   d      }|rt/        t        j0                  t        j2                  t        j4                  | j                         nbd| j                  z   dz   }| j                  Dt/        t        j0                  t        j2                  t        j4                  | j                         d}|t6        j8                  d<   t        j:                  t+        j<                  |             | j                  r t        j>                  jA                  d|       | j                  gd \  }}t        jB                  d!vr| j                  | j
                  }}	 t        j>                  jA                  d"t        jD                  ||      d          |s| jP                  r/	 t        jR                  jU                  d%d&t        jV                  z   d'      }|jY                  d(      rt        t[        d)      t]               z          |d(   D ]  }t        t[        d*      t^        j^                  ja                  |d+   d,z        jc                         z          t        t[        d-      tM        |d.   d/0      z          |d1   je                         }tg        |      d2kD  st        t[        d3      |d2   z          |dd  D ]  }t        d/|z            d| _4        d | _        d5| _5        d| _6        | j                  | jP                  s|sto        |        n| jp                  rts        |        | j                  r| j                  sd6}d7t[        d8      z   d9z   t[        d:      z   d;z   }t_        jt                  t        | j                  d<      d,z  =      }t        tM        |j'                  t        j>                  jw                         ||>                   y y y # t        t        f$ r t                Y nt        j                  $ r}
|
j                   dk(  rd}d   |d   f}Y d }
~
b|
j                   dv rH|dk  r1|
j                   dk(  rt#        d       nt#        d       |dz  }Y d }
~
t        dt$               n t        dj'                  |
      t$               Y d }
~
n9d }
~
wt(        $ r*}
t        dj'                  |
      t$               Y d }
~
nd }
~
ww xY w|dk  r# tF        $ rS}t        d#tH        jJ                  $       t        tM        tO        |            tH        jJ                  $       Y d }~d }~ww xY w# t(        $ r%}
t#        d4j'                  |
             Y d }
~
d }
~
ww xY w)ANr   Tzhttps://auth.dnanexus.comFz`Error: Only one of --host and --port were provided; provide either both or neither of the valuesr	   c                  >    t        j                  dz   | dd d      S )Nz/system/newAuthTokenFT)prepend_srvauthalways_retry)r?  DXHTTPRequest)r   
authservers    r   	get_tokenzlogin.<locals>.get_tokenN  s*    %%j1G&G27dQUW Wr   c                 l   | r| \  }}nd }|sXdt         j                  v r8t        dt         j                  d   z   dz         xs t         j                  d   }nt        d      }|sXt        j                  j                  d|       t        j                         }|rt        d      nd }t        |||      S )NDX_USERNAMEz
Username []: z
Username: zVerification code: )usernamepasswordotp)osenvironr   r?  configwritegetpassdict)reuseget_otpr\  r]  r^  s        r   get_credentialszlogin.<locals>.get_credentialsR  s    %*"("$

2#(

=8Q)QTY)Y#Z#w^`^h^hiv^w#(#6	 #
 !!-:"??,29%-.tCH#FFr   zAcquiring credentials from )r   FN   )re  rf  expiress)futuredefault_unitOTPRequiredErrorr\  r]  )UsernameOrPasswordErrorOTPMismatchErrorrn  z"Incorrect username and/or passwordzIncorrect verification coder   )
arg_parserzLogin error: {}access_token
token_type)
auth_tokenauth_token_typez{"auth_token":"z","auth_token_type":"Bearer"}DX_SECURITY_CONTEXTNN)zapi.dnanexus.comstagingapi.dnanexus.comrZ  zTCould not obtain username from auth server. Consider setting both --host and --port.r   dxclientr   )clientversionmessageszNew messages from z	Date:    date  z	Subject: titlez	         subsequent_indentbodyr   z	Message: z%Error while retrieving greet data: {}
CONTRIBUTEzdYou are now logged in. Your credentials are stored in {conf_dir} and will expire in {timeout}. {tip}zUse zdx login --timeoutz$ to control the expiration date, or 	dx logoutz to end this session.)rl  )seconds)conf_dirtimeouttip)NFr   )<r   savers  tokenhostportrJ   r?  get_auth_server_nameprotocolr   rS   r  KeyboardInterruptEOFErrorrL   r;  rP   parserformat	Exceptionr   dumpsset_apiDEFAULT_APISERVER_PROTOCOLDEFAULT_APISERVER_HOSTDEFAULT_APISERVER_PORTr_  r`  set_security_contextr   ra  rb  APISERVER_HOST	user_inforK   r   r   rg   r   stagingapisystem_greetTOOLKIT_VERSIONr-  r_   ra   datetimefromtimestampctime
splitlinesr=  currentr   publicsetenvprojectspick_and_set_project	timedeltaget_user_conf_dir)r   default_authserverusing_defaultrX  rg  attempt	using_otpre  credentials	token_resesec_contextr  r  detailsgreetingmessager  linemsgr  r  rW  s                         @r   loginr  :  s}   	4Mtzz__
 zzII499#45wyz{..tyy$))T]]S
"&88	W	G  	+j89$2!ElI-E9M% 5.B4<<X\kn.o 5(35	. JJi.G\efr\stuD33T5P5PRVRmRmosoxoxy'$**47VV99D33T5P5PRVRmRmosoxoxy M(3BJJ$%djj56yy/= zz
d&UUDII$D	7KKmT^^D$-G
-ST 	Dxx,,
sSWSgSgOg-hiH||J'd/0=?BC'
3 0G${+h.?.?.M.MgV\o_cNc.d.j.j.llm${+d773CW\.]]^"6?557D4y1}d;/$q'9:$(H 0D!%$,/00 DLDIDJDKyyT\\-t	T"yytt0114ZZ]abm]nn%&$$-A$,,]`-aei-ijd3::t{{'D'D'F&-"%  ' ( 	) $yY &x0 
?? M66// $I(4k*6MNEVVNN{66%>> !EF !>?1  !ERXY.55a8VL I*11!4HHI3 lf  	7horoyoyz$s7|$3::66	7$  	D8??BCC	Dsn   *S' ,7W2 3C9Y -4Y 'W&W&V05>V092V00W&< W!!W&2	Y;AY		Y	Y?Y::Y?c                    t         j                  t        j                  | j                  | j                  | j
                        }t        dj                  |             t         j                  j                  d   }	 |j                  t              }t        j                  |      j                         }t        j                  |dz   t        |      dd      }t        d|       t&        d	   rd t         _        y t         j(                  j+                  d
d        y y # t         j                   $ r}t        t#        |             Y d }~cd }~w t%                Y txY w)NzDeleting credentials from {}...rs  z/system/destroyAuthToken)tokenSignatureFr   rS  max_retrieszDeleted token with signaturer   ru  )r?  AUTH_HELPERr  r  r  r  r   r  security_contextencoder
   hashlibsha256	hexdigestrV  rd  rL   rO   rJ   r   ra  rb  )r   rW  r  	token_sigresponser  s         r   logoutr    s   #..tyy$))T]]S
/66zBC  11,?	LL.Eu-779I))*7Q*Q*.i*H6;679H 0)<
 #DKK3T:) $  	'"1%&&	Js   ?A*D   E3EEc                     t         j                  j                  | ||       |rt         j                  j                          y y )N)DX_APISERVER_PROTOCOLDX_APISERVER_HOSTDX_APISERVER_PORTr?  ra  r   r  r  r  r  rb  s       r   r  r    s;    KKX)-)-  /  r   c                    t         j                  '| t         j                  d<   |t         j                  d<   n| t         j                  d<   |rt         j                  j                          t        j                  |        y )NDX_PROJECT_CONTEXT_IDDX_PROJECT_CONTEXT_NAMEDX_WORKSPACE_ID)r?  JOB_IDra  r  set_workspace_id)r6  rb  r;  s      r   set_projectr    sZ    {{/6+,15-.)0%&'"r   c                     t         j                  j                  |        |rt         j                  j                          y y )N)	DX_CLI_WDr  )r  rb  s     r   set_wdr    s/    KK( r   c                     | }d }|t         j                  v rt         j                  |   }|d|z   dz   z  }n|dz  }	 t        |      }|dk7  r|S ||S )Nz [r[  : r   )r_  r`  r   )
prompt_strenv_var_strpromptdefaultvalues        r   prompt_for_env_varr    sj    FGbjj **[)$.5(($
fB;L N r   c           
         	 t        j                  d| j                  d| j                  rdn| j                  | j                  s| j                   nd | j                  r| j                  nd d      }d}d}	 g }t        d      D ]&  }	 t        d       } n|j                  |       d}( |sVt        j                  dd	t        d
t        d      z   dz   dz   t        d      z   dz   t        d      z   dz         z   d	z          nt        |      dk(  rt        dd       |rZ| j                  sL| j                  dk(  r=t        d       t        t        dt        d      z   dz   t        d      z   dz                d}|D cg c]  }|d   	 }}	 |j                  t         j                         }	t        d       | j                  rt        d       n%t        dj#                  | j                               t%        t&        |D cg c]  }|d   d   dz   |d   z   d z    c}|	t        |      dk(  !      }
|
d"k(  rt        d#t        ||
   d   d         z          t)        ||
   t*        d$    xs | j,                  ||
   d   d   %       ||
   d   d   t*        d&<   t/        d't*        d$    xs | j,                         y #  t        d       Y ^xY w#  t        d       Y OxY wc c}w #  d }	Y ExY wc c}w )(NTglobVIEW
   )r.  r;  	name_moder   explicit_permsr  first_page_sizez&Error while listing available projectsFr   r   zANo projects to choose from.  You can create one with the command dx new projectz1.  To pick from projects for which you only have z VIEW permissions, use zdx select --level VIEW or zdx select --public.z No projects left to choose from.rh  r  r   z
Note: Use zB to select from projects for which you only have VIEW permissions.idzAvailable public projects:z'Available projects ({level} or higher):r   r.  r;   (r   ))more_choicesmzSetting current project to: r   r;  r   /)r?  find_projectsr;  r  r   rJ   rangenextr>  r  exitrg   r_   r=  r   indexWORKSPACE_IDr  r   rp   r  r   r  r  )r   result_generatorany_results
first_passresults_retvalrH  project_idsr  choices              r   r  r    s+   ;--t3799?C{{VPTPZPZUYU`U`$++ofjEI[[dkkVZ>@B KJ
r 	AC.5 ~NN6"K	 KK4$'j'+,<'=(>@s(t'@(ACGH`Ca(bdj(k (,,@'A(B EH(H #I I LPP Q \Q7;;;4::#=b	d<$/G*HH6QTXYmTnn_` a bJ29:vd|::	!''(9(9:G 	b	;;./;BBBTU$cjkY_6*-f5<vgNQTTk!(+G(:= S=04
8STZ8[3\\]F+}1E-E-RY`agYhisYtu{Y|}#*6?:#>v#FE- 3E-00=DII>m;9:CAB( ;
	G ls0   A/J? K>K%K* K4
?KK"*K1c                     t         j                  t        dd       t        j                         }| j                  rt        |       y t        t         j                  j                  |      d          y )Nz8You are not logged in; run "dx login" to obtain a token.rh  handle)r?  r  rJ   whoamiuser_idr   r  user_describer   r  s     r   r  r  =  sN    KQOkkmG||gdhh$$W-h78r   c                 |   t         d   sd| _        | j                  rt        j                  j                          n=	 t        dd      }t        dd      }t        dd      }t        |||| j                         | j                  r(d | _	        d
| _
        d
| _        d| _        t        |        y y #  t        d	      xY w)Nr   Tz.API server protocol (choose "http" or "https")r  zAPI server hostr  zAPI server portr  zError setting up API variablesFr  )r   r  r  r?  ra  r  r  r   r  r;  r  r   r  )r   api_protocolapi_hostapi_ports       r   r  r  F  s    	||	?-.^`wxL)*;=PQH)*;=PQHL(Hdii@ }}	!
T" 	?=>>s   <B. .B;c                     | j                   rt        d       y t        j                  j	                  | j
                         y )Nz>The clearenv command is not available in the interactive shell)reset)r   r   r?  ra  clearr  r   s    r   clearenvr	  [  s0    NOKKDJJ'r   c                    | j                   rt        j                  <t        dt	        j
                  t        j                  j                        z   dz          t        j                  t        dt        j                  z          t        j                  t        dt        j                  z          t        j                  t        dt        j                  z          t        j                  t        dt        j                  z          y y | j                  rd}t        j                  4t        j                  j                  j                  dd       }||d	|z   z  }t        j                  |d
t        j                  z   z  }t        j                  |dt        j                  z   z  }t        j                  |dt        j                  z   z  }t        j                  |dt        j                  z   z  }t        |       y t        j                  6t        dt        j                  j                  j                  dd      z          t        dt        j                  z          t        dt        j                  z          t        dt        j                  z          t        dt        t        j                        z          dt        j                  v r8t        dj!                  t        j"                  j                  d                   t        dt        j"                  j                  dd      z          t        dt        t        j                  j                  d            z          y )Nzexport DX_SECURITY_CONTEXT=''zexport DX_APISERVER_PROTOCOL=zexport DX_APISERVER_HOST=zexport DX_APISERVER_PORT=zexport DX_PROJECT_CONTEXT_ID=r   rs  z --auth-token z --apiserver-protocol z --apiserver-host z --apiserver-port z --project-context-id zAuth token used		nonezAPI server protocol	zAPI server host		zAPI server port		zCurrent workspace	r  zCurrent workspace name	"{n}")nzCurrent folder		r  NonezCurrent user		rZ  )bashr?  r  r   r   r  r  APISERVER_PROTOCOLr  APISERVER_PORTr  dx_flagsr-  r   r_  r`  r  ra  )r   	flags_strr  s      r   envr  a  s   yy'04::d>N>N>_>_3``cffg"".1D4K4KKL*-0C0CCD*-0C0CCD(1D4E4EEF )		'$$5599,ME -55	"".1D4K4KKKI*-0C0CCCI*-0C0CCCI(1D4E4EEEIi''$*:*:*K*K*O*OP\^d*eef%(?(??@#d&9&99:#d&9&99:#c$*;*;&<<=$

21884;;??Kd;e8fg"T[[__[&%IIJ 3rzz~~m'D#EEFr   c                  *   d } t         j                  Ct        d   :	 t         j                  j	                  t         j                        d   }|t        d<   t        d   -t        d   dz   t         j
                  j                  dd      z   } | S #  Y <xY w)Nr   r;  r   r  r  )r?  r  r   r  project_describera  r-  )pwd_str	proj_names     r   get_pwdr    s    G$' HH55d6G6GHP	'0m$ ]'&,t{{{C/PPN	s   9B Bc                 L    t               }|t        |       y t        dd       y )NzCurrent project is not setrh  )r  r   rJ   )r   r  s     r   pwdr    s!    iGg-q1r   c                 v   t        j                  | j                        }| j                  d| j                  dk(  rt        j
                  nt        | j                  d      5 }|j                         }	 t        j                  |      }d d d        d }	 t        j                  d| j                  z   dz   | j                  z   |      }	 t        t        j                  |d             y # t        $ r t        dd       Y ww xY w# 1 sw Y   |xY w#  t                Y WxY w# t        $ r t        dd       Y y w xY w)	N-rz0Error: file contents could not be parsed as JSONrh  r     indentz2Error: server response could not be parsed as JSON)r   r   
input_jsonr   r   stdinopenreadr   rJ   r?  rV  resourcemethodr   r  )r   
json_inputfdr   resps        r   r  r    s   DOO,Jzz::,cii$tzz32G 	PB779DP!ZZ-
	P D!!#"5";dkk"I",.Jdjja()  PKQOP		P 	P
  JEqIJsH   !D3C(3D  D  (D =D?D  DDD D87D8c                 D   d| j                   vr| xj                   dz  c_         t        t        | j                   d      \  }}}| j                  dk7  r>d| j                  vr0d| j                  vr"d| j                  j	                         z   | _        | j                  | j
                  d}| j                  s| j                   |d<   	 t        j                  j                  ||      }t        d	| j                  z   d
z   |z   dz   d   z   dz          y #  t                Y 9xY w)Nr   r6  PUBLICr  @user-)inviteer   suppressEmailNotificationzInvited z to r  r   r  )r6  r   rz   r/  lowerr   
send_emailr?  r  project_inviterJ   r   )r   r6  _noneproject_invite_inputr*  s        r   r5  r5    s     $,,$%:%)\\9>GUE||xCt||$;4<<@W!3!3!55'+||djjI??@D<O89xx&&w0DE 
*t||
#f
,w
6
=W
MPS
ST
s    D Dc                    d| j                   vr| xj                   dz  c_         t        t        | j                   d      \  }}}| j                  dk7  r0d| j                  vr"d| j                  j	                         z   | _        	 t
        j                  j                  || j                  d i       t        d| j                  z   dz   |z          y #  t                Y -xY w)Nr   r6  r,  r  r.  z
Uninvited  from )
r6  r   rz   entityr1  r?  r  project_decrease_permissionsrJ   r   )r   r6  r4  s      r   uninviter:    s     $,,$%:%)\\9>GUE{{h3dkk#9 1 1 33--gT7JK 
,
$x
/'
9:
s   ,C Cc                 .   | j                   ~t        d| j                         dk7  r| j                   | _        n| j                   dz   | _        t        |        t	        dt        d| j                         d   j                  dd             y t        |        y )Nr   r  zSelected projectr   z\:)r6  rw   pathr  r   r   replacer  r   s    r   selectr>    ss    ||T\\2b8DIs*DI
4 /#t||"DQ"G"O"OPUWZ"[\T"r   c                 8   t        t        | j                  d      d d \  }}|pt        t        j                  |      j
                        d   }|t        j                  k7  sdt        j                  vr,t        |t        d    |       |t        d<   nt        dd	       	 t        j                  t        j                        }|j                  |d
       t        |t        d           y #  t        t        |dz   t        j                  z         d	       Y BxY w)Nr  r	   r;  r  r   r  r   z#Error: No current project was givenrh  foldersr  onlyz-: No such file or directory found in project )r   rz   r<  r?  get_handlerr.  r  r_  r`  r  r   rJ   list_folderrg   r  )r   r6  
folderpathproject_namedxprojs        r   r  r    s    "#8$))XNrPQRGZ 0 0 9 B BCFK d'''+DBJJ+VU=%9!9M#/E- 6:l!!$"3"34*9= :5//0lj#RRUYUfUffgijks   !6C, ,+Dc                 .    | d   d   j                         S Nr.  r;  )r1  xs    r   	cmp_namesrL    s    Z= &&((r   c                 <   t        t        | j                  d      \  }}}|t        dd       t	        j
                  |      }d}| j                  r| j                  s| j                  sd}n)| j                  s| j                  r| j                  sd}nd}d }|j	 | j                  rt        d	d	d
      }n1| j                  rt        t                     }nt        d	d	d	d      }|j                  |||| j                        }| j                  rNt        t!        d      dz   |j#                         d   z   dz   |z   dz          t        t!        d      dz   |z          | j                  s| j                  rddgng }||d   z  }|D ]  }	| j                  r-t        t%               t'               z   |	z   t)               z          <t        t%               t'               z   t*        j                  j-                  |	      z   dz   t)               z           | j                  st/        |d   t0              |d<   | j                  r't3        |d         dkD  rt5                nt        d       | j                  s+| j                  st7        j8                  d |d   D              }
|d   D ]Z  }| j                  rt        |d          | j                  rt;        |d   d       ;t=        |d   
|d   d      dkD  rd	nd       \ y y t7        j8                  d  |D              }
|D ]f  }|d   d!   |k(  s| j                  rt        |d          *| j                  rt;        |d   d       Gt=        |d   |
|d   d      dkD  rd	nd       h y #  t                Y y xY w)"NF)ask_to_resolveFCurrent project must be set or specified before any data can be listedrh  r   objectsr@  r   T)r  r;  r:  )r  classr;  )r  r.  rB  includeHiddenzProject:r   r;  r  r  zFolder :z/.z/..r  keyr   z#No data objects found in the folderc              3   ,   K   | ]  }|d    d     ywr.  r;  Nr   .0objs     r   	<genexpr>zls.<locals>.<genexpr>/  s     5iRUc*of6M5i   r  r.  )include_projectr   )print_idc              3   ,   K   | ]  }|d    d     ywrW  r   rX  s     r   r[  zls.<locals>.<genexpr>;  s     )\c#j/&*A)\r\  r6  )r   rz   r<  rJ   r?  rC  rZ  r@  fullbriefrd  verboser   rD  r   r   r^   r.  r_   rY   r`   r_  basenamesortedrL  r=  r   collectionsCounterr   r   )r   r6  rE  entity_resultsrG  rB  r*  describe_inputfolders_to_printr  name_countsrZ  rH  s                r   r$  r$    sK   *23H3799BG+I'GZ Y[\]g&FDxxTYYXX$,,tyyD,	zz!%D$-G!H!%-A-C!D!%D4QU-V!W%%Z/=+/48HH & >D ||i
+c1FOO4Ef4MMPTTW^^addei
+c1J>?8848HHD%="  DO3 . YFyydftvo6?@dftvo0@0@0HH3NQUQWWX	Y
 <<"(ii"HY<<4	?+a/)+CDzz$,,"-"5"55iY]^gYh5i"iK	? }Czzc$i('JO%c*oTWXbTcdjTkHlopHpv{|}  ( ")))\^)\\$ 
	F j!),7::&,'\\#F:$6N!&"4{SYZdSeflSmGnqrGrtx}~
		Js   I'N Nc           
         d}| j                   D ]^  }	 t        |d      \  }}}|t        t	        d|z   dz                	 t        j                  j                  ||| j                  d	       ` |rt        dd       y y # t        $ r2}t        t	        d|z   dz   t        |      z                d}Y d }~d }~ww xY w# t        $ r7}t        d
|z   dz   |z          t        dt        |      z          d}Y d }~d }~ww xY w)NFr  r  Could not resolve "": T"Could not resolve the project of ""r  parentszError while creating  in   r   rh  )pathsry   r   r   rg   r   r?  r  project_new_folderrq  r  rJ   )r   	had_errorr<  r6  rE  r4  r  s          r   r  r  H  s   I

 	)5dX)N&GZ
 ?$;dBSHIJ	HH''JSWS_S_1`a  Q   	$,t3e;c'lJKLI	  	)J6?'IJ$W%&I	s/   B -B> 	B;	(B66B;>	C>-C99C>c           
      $   d}| j                   D ]o  }	 t        |d      \  }}}|t        t	        d|z   dz                	 d}|s:t        j                  j                  ||dd	      }d
|vrt        d      |d
   }|s:q |rt        dd       y y # t        $ r2}t        t	        d|z   dz   t        |      z                d}Y d }~d }~ww xY w# t        $ r7}t        d|z   dz   |z          t        dt        |      z          d}Y d }~d }~ww xY w)NFr  r  rl  rm  Trn  ro  )r  partial	completedError removing folderError while removing rr  rs  r   rh  )rt  ry   r   r   rg   r   r?  r  project_remove_folderrK   r  rJ   )	r   rv  r<  r6  rE  r4  r  ry  r*  s	            r   r  r  ]  s2   I

 	)5dX)N&GZ
 ?$;dBSHIJ	Ixx55g*KO@Q Rd*!"9:: -	  * Q %  	$,t3e;c'lJKLI	  	)J6?'IJ$W%&I	s/   B=C	C(CC	D-D

Dc           
         d}i }| j                   r| j                  s| j                  D ]  }	 t               5  t	        |d| j
                        \  }}}d d d        dk(  rt        d       t        d       t        dj                  t        d                   t        d	       t        d
j                               t        d	       t        d       t        d       t        d       t        dd        | j                  D ]  }	 t	        |d| j
                        \  }}}|d}t        t        d|z   dz                ?||vrg g d||<   |`|A| j                   st        t        d|z   dz                d}x||   d   j                  |       t        t        d|z   dz                d}||   dxx   |D cg c]  }|d   	 c}z  cc<    |D ]~  }||   d   D ]E  }		 d}
|
s>t        j                  j!                  ||	ddddd      }d|vrt#        d      |d   }
|
s>G 	 t        j                  j%                  |||   d   ddd        |rt        dd       y y # 1 sw Y   xY w# t        $ r}Y d }~]d }~ww xY w# t        $ r3}t        t        d|z   dz   t        |      z                d}Y d }~d }~ww xY wc c}w # t        $ r8}t        d|	z   dz   |z          t        dt        |      z          d}Y d }~*d }~ww xY w# t        $ rQ}t        dt'        j(                  ||   d         z   dz   |z          t        dt        |      z          d}Y d }~d }~ww xY w) NFT
allow_multall_multr  r   zK===========================================================================zD*     {}: Recursive deletion will remove all files in project!     *z	RED ALERTzK*                                                                         *z-*                  {}                       *zK*   Please issue 'dx rm -r --force' if you are sure you want to do this.  *rh  rl  rm  z" to a project)r@  rP  zDid not find "zU" as a data object; if it is a folder, cannot remove it without setting the "-r" flagr@  zPath z: resolved to a project; cannot remove a project using "rm"rP  r  )r  recurseforcerx  )rU  ry  rz  r{  r7  rs  )rP  r  )	recursiver  rt  rl   rz   r   r   r  r\   rJ   r  rg   r   r>  r?  r  r|  rK   project_remove_objectsr   r  )r   rv  r  r<  r6  rE  rg  r  rH  r  ry  r*  s               r   r%  r%  z  s   IH ~~djjJJ 	DZ z:OPTaeptpxpx:y7GZz$)?"Igh`gghklwhxyzghIPPQXYZghghgh"IRO	( 

 X	2GY]hlhphp2q/GZ
 ?I$,t36FFGH(",.2 >HW!%~~$/$6  :Q   Q  R  S $IW%i077
Cd7T>,hhij 	Wi(,WfVD\,WW(7X:  w'	2 	!F!!	#8899'EKX\DHUY;[GK : MD #$.%&=>> $[ 1I $		! 	HH++G8@8I)8T_c,d9= , ?'4 Q Sz z    	$,t3e;c'lJKLI	. -X  !-6AGKLdS\)* 	!  	)DJJx7H7S,TTW__biij$W%&I	sy   
I7I*B%I7JK(AK-+L*I4	/I77	JJ	K
(KK
	L-LL	M0AM++M0c           
         d}| j                   D ]  }t        d|      }t        |      dkD  st        |      dk(  r%|d   dk(  rt        t	        d|z   dz                d}Qt        |      dk(  r|d   dk(  rt        t	        d             d}~t        t        |d         }|t        t	        d|z   d	z                d}	 t        j                  j                  |      }| j                  rkt        t	        d
|d   z   dz   |z   dz         dz         }t        |      dk(  s|j                         d   dk7  r!d}t        t	        d|d   z   dz                G	 t        j                  j                  |d| j                   i       | j                   st        t	        d|d   z   dz                 |rt%        dd       y y # t        j                  $ r}|j                  dk(  rt        t	        d      dz         }t        |      dk(  s|j                         d   dk7  r%d}t        t	        d|d   z   dz                Y d }~3t        j                  j                  |ddi       n|Y d }~d }~ww xY w# t"        $ r t%        dd       Y }t&        $ r t%        dd       Y t(        $ r3}t        t	        d|z   dz   t+        |      z                d}Y d }~d }~ww xY w)NFr   r   r   zUnable to remove "zA": a nonempty string was found to the right of an unescaped colonTzGUnable to remove ":": to remove the current project, use its name or IDz$": could not resolve to a project IDzAbout to delete project "r;  " (r  z
Please confirm [y/n]: yzAborting deletion of project "ro  terminateJobsr   z8WARNING: there are still unfinished jobs in the project.z3
Terminate all jobs and delete the project? [y/n]: zSuccessfully deleted project "r   rh  zWas unable to remove , )r  r   r=  r   rg   r   rx   r?  r  r  confirmr   r1  project_destroyrL   r;  quietr  rJ   r  r  r   )	r   rv  r6  
substringsproj_id	proj_descr  apierrorr  s	            r   r4  r4    s   I== -$S'2
z?Q3z?a#7GAJ#<M$+g58{{|}Iz?aqzS ddef 	7AG?$+g58^^_`I	11':I||d#>6AR#RUZ#Z]d#dgj#jk  oI  I  Ju:?ekkmA&6#&= $I$?)FBSSVYYZ[#((?DT2UV ::d;i>OORUUVWM-\ Q ' ?? 	#==N2!$'a"b  f\  #\  ]E5zQ%++-*:c*A$(	d#CiPVFW#WZ]#]^_ HH,,W6MN"N O	#  	RO  	RO 	$.84?#g,NOPI	s\    BI4-G )I4 I1A)I,<I4%I,'I4,I11I44KK#K+(KKc           	         t        t        | j                  d      \  }}}	 |
t               t	        j
                  |      }|j                  |d       t        | j                        d
k(  rt        dd       g }g }| j                  D ]g  }t        t        |d| j                        \  }}}
||k7  rt        t        d      d       |
|j)                  |       R||
D cg c]  }|d   	 c}z  }i 	 t        j                  j#                  |||| j$                  d       y #  |t        dd       t        | j                        dk7  rt        dd       t        d	|      }|d
k(  rd	}n|d | }||dz   d  j                  dd	      }	 j                  |d       n#  t        dd       Y nxY wt        t        | j                  d
   d| j                        \  }}	}
||k7  rt        t        d      d       |
Q|	d	k(  rt        t        d      d       	 t        j                  j!                  ||	|d       Y y #  t                Y nxY w	 |
d
   d   d   |k7  rEt        j                  j#                  ||
D cg c]  }|d   	 nc c}w c}|| j$                  d       |
D ]$  }t	        j&                  d	|d   z   dz   ||d       & Y y #  t                Y nxY wY xY wc c}w #  t                Y y xY w)Nr  r  r@  rA  zCannot move to a hash IDrh  r   z%The destination folder does not existr  r   z\/Tr~  zRError: Using "mv" for moving something from one project to another is unsupported.zXCannot rename root folder; to rename the project, please use the "dx rename" subcommand.)r  newpathr.  r  )rP  destinationtargetFileRelocation/renamer6  r;  zNo sources provided to moveznUsing "mv" for moving something from one project to another is unsupported.  Please use "cp" and "rm" instead.)rP  r@  r  r  )r   ry   r  r   r?  rC  rD  rJ   r=  sourcesrw   r=  rz   r   rg   r  project_rename_folderproject_movetarget_file_relocationrV  r>  )r   	dest_proj	dest_pathr4  dx_destlast_slash_posdest_folder	dest_namesrc_projsrc_pathsrc_resultsrH  src_objectssrc_folderssourcesrc_folderpaths                   r   r&  r&    s'   "*<9I9IT\"]Iy%4,""9-99=d 4<<A.2KK,, 
D089N9?DHSWS[S[1]-.+ y T  K  L  NO  P~.{CVF4LCCK
Dh*5*5.77;7R7RT	UC//3t||!<a@-c9=QK#O^4Knq012::4E		A{C	A<a@ +33H37<<?>BTXX+W'(K y Tnoqrs3xy{|}..xHYb9cd
q>*-h7;FHH))(R]6^vd|6^6^:ECGC^C^+`a * <F&&sVD\'9I'E3;09(;<< 
  D
sh   4D% !K#5/K( %A%K FK F/-A)K #H<<I
K ,K:JAKKK (K6c                    t        t        | j                  d      \  }}}|t        t	        d      d       t        j                  |      }t        j                         }	 |j                  ddi      d   D cg c]  }|j                  |dk7  r|dz   nd      r|! }}|D cg c]  }|t        |      d   }}|D ]l  }|}|j                  d      D ]T  }	|	d	k(  r	t               t               z   |	z   t               z   }
|j!                  |
t        j                                ||
   }V n t#        t        j$                  ||dt'        t)               
            t*              D ]  }|}|d   d   t        |      d  j                  d      D ]0  }	|	d	k(  r	t               t               z   |	z   t               z   }
||
   }2 | j,                  rt/        |d         }n5|d   d   }|d   d   dv r#t               t1               z   |z   t               z   }d ||<    t3        t5        |t               t               z   | j                  z   t               z                y c c}w c c}w #  t                Y y xY w)Nr  r  rO  rh  r@  Tinput_paramsr  r   rQ  )r6  r  r  r.  rT  r.  r;  rR  )r  r   )root)r   rz   r<  rJ   rg   r?  rC  re  OrderedDictr.  r	  r=  splitr_   rY   r`   
setdefaultrd  find_data_objectsrd  r   rL  longr   r[   r   rm   )r   r6  rE  r4  rG  r  r  r@  subtreepath_elementpath_element_descitem	item_descs                r   r  r  T  s   !)*?3;"=GZ ^_abcg&F""$D (.iQUEV(WXa(b [f''jC>Oc)9UXY  [ [;BDF3z?+,DD 	5FG &S 1 52%$(FTVOl$BTV$K!""#4k6M6M6OP!"345	5 411'*:>UiUkIln(* 	&D G $Z 0 :3z?;K L R RSV W 52%$(FTVOl$BTV$K!!"34	5
 yy)$z*:;	 ,V4	
#G,0FF $ 09 <tv EI!%GI	&" 	k$dftvo		&ADF&JLM;[D8
s+   "I% ;$II% %I :F I% 
I% %I3c                 @   fd}fd}	 t        | j                        dk(  rt        d      i }g }d|d<   | j                  r/| j                  s| j
                  s| j                  rt        d      d|d<   t        | j                        rWt        j                  G	 t        j                  j                  t        j                  d	d
dii       t        j                  |d<   t        | j                        r9|j!                  d       | j                  rt"        D ]  }|j!                  |        t%        | j                        r9|j!                  d       | j                  rt&        D ]  }|j!                  |        t        |      dkD  rd|d<   |D ci c]  }|d c}|d	<   | j(                  /t        | j                        st+        d       | j(                  |d<   	 t-        | j                  dd|      \  }}}	d}g }t5               i }d|d<   | j                  r
d|d<   d|d<   |	8| j                  d   dk(  r|	 t        j                  j                  ||      }d}| j                  r|j!                  |       nA| j                  rt7        |d          n&t7                       t9        || j                         nt;        | j                        r	 t        j                  j                  | j                  |      }d}| j                  r|j!                  |       nA| j                  rt7        |d          n&t7                       t9        || j                         |	t        |	      dkD  rd}|	D ]  }t%        |d
         rF| j                  r:t        j<                  |d
         j?                         }|d   jA                  |       | j                  r2|d   }| j                  stC        ||d
         }|j!                  |       | j                  rt7        |d   d          t7                       t9        |d   | j                  xs | j
                          tE        | j                        sd| j                  vr| j                  jG                  d      s| j                  jG                  d      r' ||| | j                  jI                  d      d         }n	 |||       }|rd}| j                  jG                  d      r	 t        j                  jK                  | j                  ddd       }d}| j                  r|j!                  |       n\| j                  r*t7        t1        |d!         d"z   t1        |d#         z          n&t7                       t9        || j                         n| j                  jG                  d$      s| j                  jG                  d%      r	 t        jL                  d&| j                  z   d'z   i       }d}| j                  r|j!                  |       nA| j                  rt7        |d
          n&t7                       t9        || j                         | j                  r| jN                  r!t7        t        jP                  |d()             y t        |      d*kD  rt        d+| j                  z   d,z         t        |      dk(  rt        d-| j                  z         t7        t        jP                  |d   d()             y |st        d.| j                  z         y # t        j                  $ r}t        |t              s|Y d }~d }~ww xY wc c}w # t.        $ r>}
t1        |
      j3                  d      rt        t1        |
            d\  }}	Y d }
~
d }
~
ww xY w# t        j                  $ r}t        |t              s|Y d }~d }~ww xY w# t        j                  $ r}t        |t              s|Y d }~d }~ww xY w# t        j                  $ r}t        |t              s|Y d }~d }~ww xY w# t        j                  $ r}t        |t              s|Y d }~d }~ww xY w#  t+                Y y xY w)/Nc                    |dv sJ d}	 |dk(  r*t         j                  j                  |j                        }n>t         j                  j	                  |j                        }t        j
                  |      }|j                  r| j                  |       nA|j                  rt        |d          n&t                       t        ||j                         d}|S # t         j                  $ r}t        |t              s|Y d}~|S d}~ww xY w)z
        Describes a global executable, i.e. either app or global workflow
        depending on the provided exec_type. Appends the result to json_output.
        Returns True if any matches were found
        )appglobalworkflowFr  r;  TN)r?  r  app_describer<  global_workflow_describe#append_underlying_workflow_describer   r>  r;  r   r   rb  rL   
isinstancer   )json_outputr   	exec_typefound_matchr   r  get_result_strs         r   describe_global_executablez,describe.<locals>.describe_global_executable  s     5565	E!xx,,TYY7xx88C??Eyy""4(d6l#n&'4.K
 	  	a!12 3 		s   CC D.DDc                      fd}d}t        j                  j                  d      D ]  } ||       d} |sKt        j                  j                  d      D ]'  }t        j                  |d         |d<    ||       d}) |S )a  
        Makes a find_apps API call and, if no matches are found, a find_global_workflows call.
        Since these two objects share namespace, either app or a global workflow will be
        found, not both. The results are appended to json_output and printed to STDOUT.
        c                     j                   rj                  | d          y j                  rt        | d   d          y t                       t	        | d   j
                         y rI  )r   r>  r;  r   r   rb  )rH  r   r  r  s    r   append_to_output_json_and_printzQdescribe.<locals>.find_global_executable.<locals>.append_to_output_json_and_print  sT    yy""6*#56fZ(01n&'6*-t||<r   FTr;  r.  r.  )r?  r@  r<  find_global_workflowsr  )r  r   r  r  rH  r  s   ``   r   find_global_executablez(describe.<locals>.find_global_executable  s    	= nn$))dC 	F+F3K	 44$))dS #%)%M%MfU_N`%az"/7"# r   r   z.Must provide a nonempty string to be describedT
propertieszKCannot request --name in addition to one of --verbose, --details, or --jsonr  r:  r  r  r6  spotCostSavingsdefaultFieldsz7Parameter --try T can be used only when describing jobstryr8  F)r   rN  r.  zcode 401rv  permissions	appCachesr  r   r;  r.  app-globalworkflow-r  r.  )appsInstalledsubscriptionsfirstr   lastorg-zteam-r  z	/describer  r   r   zMore than one match found for zC; to get all of them in JSON format, also provide the --multi flag.zNo match found for zNo matches found for ))r=  r<  r   r;  rb  r  r   rs   r?  r  r  r  rL   r  r   ru   r>  r   rv   r   job_tryrJ   rz   r   r   endswithr   r   r   rt   
DXAnalysisr.  r   r   rr   r	  	partitionr   rV  multir  )r   r  r  r(  extra_fieldsr  fieldr6  _folderpathrg  r  r  r  r   rH  default_analysis_descdesc_outputfoundr  s                     @r   r.  r.    sS   :6ttyy>QMNN 
#'
< 99$,,$,,$))jkk $
9$))$  , HH--d.?.?xZ^`dYeNf-g,0,=,=Jy)
 TYY 12||4 /E ''./ $))$ 12||9 /E ''./ |q *.J'=I#JEE4K#JJx <<#TYY'RS $Ju	13HRZX]R\4^0G[.  & 
#'
< <<(,J}%&*J{#!yy}#(; 8844WjID"&Kyy#**40d6l+n./"46 !+ 8844TYY
KD"&Kyy#**40d6l+n./"46 %>"Q&"( Q!&,/DLL,0OOF4L,I,R,R,T):&--.CD99"("4K<<&;KPT&V&&{3YY&,V45.*+vj14<<3O4<<PQ  #499(< yy##F+tyy/C/CDU/V2;diiFYFYZ]F^_`Fab.{DA"yy##G, 8811$))tfj=klD"&Kyy#**40c$w-036T&\9JJKn./"46 %%f-1E1Eg1N --cDIIo.KRPD"&Kyy#**40d4j)n./"46
 99zzdjjQ78[!A% !ADII!M  QV  "V  W  W[!Q& !6!BCCdjjQ:;4tyy@AA {   %a)9: ; $ $K  
	17|$$Z0 !W..&0#G^
	1J   %a)9: ;    %a)9: ; \   %a)9: ;    %a)9: ; 
s*  Bb A] %B3b 
]4"Ab $]9 Ab B_ b B_6 'F*b B)`) ;7b 3Ba :8b 3A2b &b ]1],&b ,]11b 9	_ 3^;5b ;_  b _3_.(b ._33b 6`&	`!b !`&&b )a<ab ab b/bb bb bc                     | j                   Ft        t        j                        dkD  r)t	        dj                  t        j                              y y )Nr   z.Cannot specify {opts} without specifying --org)opts)r   r=  DXNewUserOrgArgsActionuser_specified_optsr   r  r   s    r   _validate_new_user_inputr  p  sT     xxC 6 J JKaOIPP';; Q 
  	 Pr   c                    | j                   | j                  d}| j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j
                  *t        | j
                        }|dkD  rt        d      ||d<   | j                  | j                  |d<   | j                  d	u r| j                  |d
<   | j                  | j                  |d<   |S )zO
    PRECONDITION: `_validate_new_user_input()` has been called on `args`.
    )r\  emailr  r  middlel    H4 z(--token-duration must be 30 days or lesstokenDuration
occupationTbillToprovisioningOrg)r\  r  r  r  r  token_durationrR   r   r  set_bill_tor   on_behalf_of)r   user_new_argstoken_duration_mss      r   _get_user_new_argsr  z  s     "&"jj*Mzz!%gyy $		f{{"&++h&/0C0CD77GHH->M/*"&*ool#4"&((h$+/+<+<'(r   c                    t        |        t        j                  t        j                         dz   t	        |       dd       d| j
                  j                         z   }| j                  4t        j                  j                  | j                  t        ||              | j                  rt        |       y t        t        dj                  |                   y )Nz	/user/newFr   r  r.  zCreated new user account ({u}))u)r  r?  rV  r  r  r\  r1  r   r  
org_inviter@   ra  r   rg   r  r  s     r   new_userr    s    T" 	t002[@)$/#(#$&
 ++--GxxDHH&9'4&HIzzgd3::W:EFGr   c                 ^   | j                   d k(  rAt        rt        d      | _         n*t        t        j                         t        d      z   d       d| j                   i}| j                  r| j                  |d<   | j                  r| j                  |d<   | j                  rd|d<   | j                  rd|d	<   | j                  | j                  |d
<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  | j                  |d<   | j                  "t!        j"                  | j                        |d<   | j$                  | j$                  |d<   	 t&        j(                  j+                  |      }| j,                  rt/        |d          n-t/        t        d| j                   z   dz   |d   z   dz                | j0                  st        r7t3        dd      r)t5        |d   d| j                          t7        dd       y y y #  t                Y y xY w)NzEnter name for new project: z6No project name supplied, and input is not interactiverh  r;  r  regionTcontainsPHIdatabaseUIViewOnlydatabaseResultsRestrictedmonthlyComputeLimitmonthlyEgressBytesLimitmonthlyStorageLimitdefaultSymlinkdriver  zCreated new project called "r  r  zSwitch to new project now?Fr  )rb  r;  r  )rb  )r;  r   r   rJ   parser_new_projectformat_helprg   bill_tor  phidatabase_ui_view_onlydatabase_results_restrictedmonthly_compute_limitmonthly_egress_bytes_limitmonthly_storage_limitdefault_symlinkr   r   r   r?  r  project_newra  r   r>  r   r  r  )r   inputsr*  s      r   new_projectr    s   yyD<=DI'335=u8vvxyzdii F||<<x{{;;xxx $}!!'+#$''3.2.N.N*+!!-(,(B(B$%&&2,0,K,K()!!-(,(B(B$%'#'::d.B.B#C zz**w
xx##F+::$t*$5		AEIDQUJVY\\]^;;?}=Ych/iT
$TYY?3d# 0j?
s   -B.H H,c                    t        t        |        t        t        |        d }| j                  :t        t        | j                  d      \  }}}t        j                  |d   |      }| j                  3t
        j                  }t
        j                  j                  dd      }d }nt        t        | j                        \  }}}d }	 t        j                  ||| j                  | j                  | j                  | j                   | j"                  || j$                  | j&                  |      }| j(                  rt+        |j-                                y t/        |j1                  dd	      | j2                         y #  t5                Y y xY w)
Nr8  r  r  )dxidr6  r  r  )r6  r;  tagstypeshiddenr  r  r  r,  rq  	init_fromTincl_propertiesincl_details)r   r+   r,   initrz   r?  DXRecordoutputr  ra  r-  ry   new_dxrecordr  r  r  r  r  r,  rq  ra  r   get_idr   r.  rb  rJ   )	r   r  init_project_init_folderinit_resultr6  r  r;  dxrecords	            r   
new_recordr!    s:   $d+2D9Iyy2:;P;?99DL3N/lK MM{4'8,O	{{##c2 (t{{ CH$$W4*.))4::,0KKDOO-1\\,2+/::-1\\YP ::(//#$x((D(QSWS_S_`
s   	BE= 'E= =Fc                    d}t        t        | j                  dd| j                        \  }}}|%t	        t        d| j                  z   dz         d       |D ]1  }	 t        j                  d|d	   z   d
z   d| j                  dk(  i       3 |rt	        dd       y y # t        j                  ft        z   $ r0}t        t        |      t        j                         d}Y d }~d }~ww xY w)NFr8  Tr   r  r  rl  " to a name or IDrh  r  r  z/setVisibilityr  r   r   )r   rz   r<  r   rJ   rg   r?  rV  r  rL   rM   r   rO   r   r   r   rv  _projectr  rg  rH  r  s          r   r)  r)    s    I,45J59YY>F@Dtxx-Y)Hk>
 +dii7:MMNPQR  	sVD\14DD (4??h+FHJ Q 	 !$66 	"7+#**=I	s   .BC'7&C""C'c           	      B   t        t        | j                  d      \  }}}|%t        t	        d| j                  z   dz         d       i }|||d<   	 t        t        j                  t        j                  d|d   z   d	z   |      d
             y #  t                Y y xY w)Nr8  r  rl  r$  rh  r6  r  r  z/getDetailsr  r   )
r   rz   r<  rJ   rg   r   r   r  r?  rV  )r   r6  r  entity_resultr  s        r   r'  r'    s    *23H48II+R'G[- +dii7:MMNPQRL")Ydjj++C-2E,E,UWcdmnop
s   =B Bc                 X   d}t        t        | j                  dd| j                        \  }}}|+t	        t        d| j                  z   dz         t
        f       | j                  (| j                  t	        t        d      t        f       n| j                  !	 t        j                  | j                        }n| j                  e| j                  dk(  rt        j                  nt        | j                  d      5 }|j                         }	 t        j                  |      }d d d        nt	        t        d      t        f       |D ]"  }		 t!        j"                  d|	d   z   dz          $ |rt	        dd       y y # t        $ r}t	        d	t        f|
       Y d }~Xd }~ww xY w# t        $ r}t	        dt        f|
       Y d }~d }~ww xY w# 1 sw Y   xY w# t         j$                  ft&        z   $ r0}
t)        t+        |
      t        j,                         d}Y d }
~
d }
~
ww xY w)NFr8  Tr#  rl  r$  	exceptionexpected_exceptionsz1Cannot provide both -f/--details-file and detailsz*Error: Details could not be parsed as JSON)r,  r+  r  r  z0Error: File contents could not be parsed as JSONz,Must set one of -f/--details-file or detailsr  r  z/setDetailsr   r   rh  )r   rz   r<  r   rJ   r   r  details_filer2   r   r   r   r   r#  r$  r%  r?  rV  rL   rM   r   rO   r   )r   rv  r&  r  rg  r  r  r)  r   rH  exc_detailss              r   r(  r(    s   I,45J59YY@Dtxx-Y)Hk> ?+@499+LOb+bc&5%7	9 ||D$5$5$A=)\]&3%5	7 
	!	sjj.G 
			&,,3ciid>O>OQT9U 	&Z\779D&**T*	& 	& 	=)WX&3%5	7 ! 	sVD\1MA7K Q 1  	sAXbWdpqrr	s  &Kblan#$& &&		& 	&  !$66 	";/cjjAI	s`   F  >GF)G 	F&	F!!F&)	G2G
G
GGGH)9&H$$H)c                    d}t        t        | j                  dd| j                        \  }}}|%t	        t        d| j                  z   dz         d       |D ].  }	 t        j                  d|d	   z   d
z   d| j                  i       0 |rt	        dd       y y # t        j                  ft        z   $ r0}t        t        |      t        j                         d}Y d }~d }~ww xY w)NFr8  Tr#  rl  r$  rh  r  r  z	/addTypesr  r   r   r   rz   r<  r   rJ   rg   r?  rV  r  rL   rM   r   rO   r   r   r%  s          r   r*  r*  M  s    I,45J59YY>F@Dtxx-Y)Hk>
 +dii7:MMNPQR  	sVD\1K? '46 Q  !$66 	"7+#**=I	   +BC$4&CC$c                    d}t        t        | j                  dd| j                        \  }}}|%t	        t        d| j                  z   dz         d       |D ].  }	 t        j                  d|d	   z   d
z   d| j                  i       0 |rt	        dd       y y # t        j                  ft        z   $ r0}t        t        |      t        j                         d}Y d }~d }~ww xY w)NFr8  Tr#  rl  r$  rh  r  r  z/removeTypesr  r   r   r0  r%  s          r   r+  r+  b  s    I,45J59YY>F@Dtxx-Y)Hk>
 +dii7:MMNPQR  	sVD\1NB '46 Q  !$66 	"7+#**=I	r1  c                    d}t        t        | j                  | j                        \  }}}||| j                  d}| j
                  !t        t        d |            rt        d       |D ]=  }| j
                  | j
                  |d<   	 t        j                  d|d   z   dz   |       ? |rt        dd       y y |j#                  d      st        dd       y | j
                  t        d       	 t        j                  d|z   dz   d| j                  i       y # t        j                  ft        z   $ r0}t        t        |      t        j                   	       d
}Y d }~d }~ww xY w#  t                Y y xY w)NFr6  r  c                      t        | d          S Nr  ru   rJ  s    r   <lambda>zadd_tags.<locals>.<lambda>      i$>P:P r   ,Parameter --try T can be used only with jobsr  r  r  z/addTagsr   Tr   rh  project-z/Cannot add tags to a non-project data containerr  r   r   r<  r   r  r  anymaprJ   r?  rV  rL   rM   r   rO   r   r   r	  r   rv  r6  r  rg  payloadrH  r  s           r   add_tagsrA  w  sW   I+34Q48II48HH,>(G[. !%tyy9<<#C0PR`,a(bCD$ 	!F||'!%!""3#5
#BGL		! RO 
+BAF<<#CD	sW}z9 &		24 OO%(:: !&w/cjjA 	!	J$   D2(E) E&6&E!!E&)E7c                    d}t        t        | j                  | j                        \  }}}||| j                  d}| j
                  !t        t        d |            rt        d       |D ]=  }| j
                  | j
                  |d<   	 t        j                  d|d   z   dz   |       ? |rt        dd       y y |j#                  d      st        dd       y | j
                  t        d       	 t        j                  d|z   dz   d| j                  i       y # t        j                  ft        z   $ r0}t        t        |      t        j                   	       d
}Y d }~d }~ww xY w#  t                Y y xY w)NFr4  c                      t        | d          S r6  r7  rJ  s    r   r8  zremove_tags.<locals>.<lambda>  r9  r   r:  r  r  r  z/removeTagsr   Tr   rh  r;  z4Cannot remove tags from a non-project data containerr  r<  r?  s           r   remove_tagsrE    sW   I+34Q48II48HH,>(G[. !%tyy9<<#C0PR`,a(bCD$ 	!F||'!%!""3#5#EwO		! RO 
+GK<<#CD	sW}}< &		24 OO%(:: !&w/cjjA 	!	JrB  c                 :   d}t        t        | j                  | j                        \  }}}|D|D ]/  }	 t	        j
                  d|d   z   dz   || j                  d       1 |rt        dd	       y y |j                  d
      st        dd	       y 	 t        j                  j!                  |d| j                  i       y # t        j                  ft        z   $ r0}t        t        |      t        j                         d}Y d }~d }~ww xY w#  t                Y y xY w)NFr  r  r  r  r   Tr   rh  r;  z*Cannot rename a non-project data containerr;  )r   r   r<  r   r?  rV  r;  rL   rM   r   rO   r   r   rJ   r	  r  project_update)r   rv  r6  r  rg  rH  r  s          r   r/  r/    s   I+34Q48II48HH,>(G[. !$ 	!F!""3#5	#A/6,0II$78	! RO 
+=qA	HH##Gfdii-@A OO%(:: !&w/cjjA 	!	Js#   ,B>,D >D	&DD	Dc                    d}t        t        | j                  | j                        \  }}}t        t        |        ||| j
                  d}| j                  !t        t        d |            rt        d       |D ]=  }| j                  | j                  |d<   	 t        j                  d|d   z   dz   |       ? |rt        dd       y y |j%                  d      st        dd       y | j                  t        d       	 t        j&                  j)                  |d| j
                  i       y # t        j                  ft        z   $ r0}t        t        |      t         j"                  	       d
}Y d }~d }~ww xY w#  t                Y y xY w)NFr6  r  c                      t        | d          S r6  r7  rJ  s    r   r8  z set_properties.<locals>.<lambda>  r9  r   r:  r  r  r  /setPropertiesr   Tr   rh  r;  z5Cannot set properties on a non-project data containerr  )r   r   r<  r   r(   r  r  r=  r>  rJ   r?  rV  rL   rM   r   rO   r   r   r	  r  project_set_propertiesr?  s           r   r0  r0    s[   I+34Q48II48HH,>(G[. $d+!%T__E<<#C0PR`,a(bCD$ 	!F||'!%!""3#58H#H'R		! RO 
+H!L<<#CD	HH++GlDOO5TU OO%(:: !&w/cjjA 	!	Js$   D/,E= /E:
&E55E:=Fc                    d}t        t        | j                  | j                        \  }}}i }| j                  D ]  }d ||<   	 |||d}| j
                  !t        t        d |            rt        d       |D ]=  }| j
                  | j
                  |d<   	 t        j                  d|d   z   dz   |       ? |rt        dd       y y |j#                  d      st        dd       y | j
                  t        d       	 t        j$                  j'                  |d|i       y # t        j                  ft        z   $ r0}	t        t        |	      t        j                   	       d
}Y d }	~	d }	~	ww xY w#  t                Y y xY w)NFrI  c                      t        | d          S r6  r7  rJ  s    r   r8  z"unset_properties.<locals>.<lambda>  r9  r   r:  r  r  r  rK  r   Tr   rh  r;  z7Cannot unset properties on a non-project data containerr  )r   r   r<  r   r  r  r=  r>  rJ   r?  rV  rL   rM   r   rO   r   r   r	  r  rL  )
r   rv  r6  r  rg  r  propr@  rH  r  s
             r   r1  r1    sj   I+34Q48II48HH,>(G[. J  
4 !%Z@<<#C0PR`,a(bCD$ 	!F||'!%!""3#58H#H'R		! RO 
+JAN<<#CD	HH++GlJ5OP OO%(:: !&w/cjjA 	!	Js$   D# "E1 #E.>&E))E.1E?c                    t        t        | j                  d      \  }}}|%t        t	        d| j                  z   dz         d       |d   d   dk7  rt        t	        d	      d       | j
                  |d   d
   | _        	 t        j                  |d   |      }t        j                  d|j                        r|j                  nt        j                  j                  }|j                  d| j                  rt        | j                        dz  nd| j
                  |      \  }}t        |       y #  t                Y y xY w)Nr8  r  Could not resolve  to a data objectrh  r.  rR  r   z7Error: dx download is only for downloading file objectsr;  r  r6  z^project-[a-zA-Z0-9]{24}$Tr}  iQ )preauthenticateddurationfilenamer6  )r   rz   r<  rJ   rg   rV  r?  DXFilererF  r6  NO_PROJECT_HINTget_download_urlrU  rR   r   )r   r6  r  r(  dxfileurl_headerss          r   make_download_urlr^    s   *23H$))^f*g'G[-*TYY69LLMqQZ )V3OPRST}}%j1&9
]40'B$&HH-I6>>$Z&..`d`k`k`{`{//eierer9LT]]9[]a9ax9=8? 0 AX 	c

s   B1D4 4Ec                    |j                   dk(  rt        j                  }n|j                   }|| d   d   j                  dd      }|j                   |j                  s|dz  }|j
                  s:t        j                  j                  |      rt        t        d|z   dz         d	       	 t        |d
      }	 t        j                  j                  | d         }j                  t!        j"                  d             |j                   dk7  r|j%                          y y #  t        d|z          Y |xY w#  t                Y jxY w)Nr  r.  r;  r  %2Fz.jsonError: path "/" already exists but -f/--overwrite was not setrh  wzError opening destination file r  r  r   )r  r   r   r=  no_ext	overwriter_  r<  existsrJ   rg   r$  r?  r  record_get_detailsrb  r   r  r,  )r(  r   r)  rV  r  s        r   
get_recordrh  6  s   {{cZZ;;$Z08@@eLH;;t{{H~~"''..":T/H47hhiklm	Ch$B((--mD.AB HHTZZ*+{{c

 	C6AB
s   +D! 8"D6 !D36Ec                 .   | j                  dd      }|j                  dk(  rt        dj                  |      dz   d       |j                  xs d}t        j
                  j                  |      r!t        j
                  j                  ||      }n|}t        j
                  j                  |      r<|j                  st        t        d|z   d	z         d       t	        j                  |       t        j
                  j                  |      s?t        d
j                  |      t        j                         t	        j                   |       t#        t	        j$                  |            r,|dk(  r|j                  st        t        d|z   dz         d       |S )Nr  r`  r  z
Error: {} z>objects cannot be dumped to stdout, please specify a directoryrh  r  ra  rb  zCreating "{}" output directoryr   databasez*" already exists. Remove it and try again.)r=  r  rJ   r  r_  r<  isdirjoinisfilere  rg   unlinkrf  r   r   r   r  r=  listdir)obj_name	obj_classr   	path_nameoutput_baseoutput_paths         r   get_output_pathru  Q  s)     e,I{{c$$Y/2rrtuv++$K	ww}}[!ggll;	:!	ww~~k"~~T/K7:kklnop
		+77>>+&.55kBT

2::k"# Z'DNNT/K7:ffgijkr   c                    |d   d   }|d   }t        ||d   d   |      }ddlm} t        dt        j
                         t        j                  || 	      }|j                  d
d
      } ||||j                  |       y )Nr.  r;  r  rR  r   dump_executablezDownloading applet datar   rS  Tr  omit_resourcesdescribe_output)
ru  dxpy.utils.executable_unbuilderrx  r   r   r   r?  DXAppletr.  rz  )	r6  r(  r   rp  obj_idrt  rx  dx_objr{  s	            r   
get_appletr  n  s    Z(0H4 F!("/
";G"D"&(K @	
##**5]]673Food37 & 9OF#'#6#6$35r   c                     | d   d   }| d   }t        || d   d   |      }ddlm} t        dt        j
                         t        j                  |      } ||||j                  	       y )
Nr.  r;  r  rR  r   rw  zDownloading application datar   )rz  )	ru  r|  rx  r   r   r   r?  DXApprz  )r(  r   rp  r~  rt  rx  r  s          r   get_appr    sl    Z(0H4 F!("/
";G"D"&(K @	
(szz:ZZFFK8K8KLr   c                    | d   d   }| d   }t        || d   d   |      }ddlm} t        dt        j
                         | d   d   d	k(  rt        j                  |      }nt        j                  |      }| d   } |||d
|       y )Nr.  r;  r  rR  r   rw  zDownloading workflow datar   r   Try  )	ru  r|  rx  r   r   r   r?  
DXWorkflowDXGlobalWorkflow)r(  r   rp  r~  rt  rx  r  r{  s           r   get_workflowr    s    Z(0H4 F!("/
";G"D"&(K @	
%CJJ7Z )Z7(&&v.#J/OFKo^r   c                 .    t        j                  |        y r  )loggingdebug)r  s    r   do_debugr    s    MM#r   c           	         t        dj                  |              t        dj                  |             | d   }| d   d   }t        dj                  |             t        || d   d   |      }t        dj                  |             d	d
lm} t        dt        j                         t        j                  |      }| d   }t        dj                  |             |j                  |j                  dk(  s|j                  dk(  r|j                  st        dd       |j                  |j                  d}t        j                  j                  ||      }	t        dj                  |	             |	d   }
|
D ]O  }	 |d   }|dk(  s|d   }|j!                  d      }|dk7  r||dz   d  }t        |       t#        || d   ||||       Q y #  d}Y PxY w)Nz'dx.py#get_database - entity_result = {}zdx.py#get_database - args = {}r  r.  r6  z!dx.py#get_database - project = {}rR  z%dx.py#get_database - output_path = {}r   rw  zDownloading database filesr   z dx.py#get_database - dx_obj = {}r  r   zhError: downloading all files from a database not allowed unless --allow-all-files argument is specified.rh  r  r  z*dx.py#get_database - list_folder_resp = {}r  isDirectoryTFr<  z	database-r  "   )r  r  ru  r|  rx  r   r   r   r?  
DXDatabaserV  allow_all_filesrJ   r  r  database_list_folderrfindr   )r(  r   r~  r6  rt  rx  r  r{  list_folder_argslist_folder_respr  dbfilestatusis_dirsrc_filenameidxs                  r   get_databaser    s   6==mLM-44T:;4 FJ'	2G077@A!&"/
";G"D"&(K 4;;KHI?	
&SZZ8__V$F#J/O/66v>? }} 48K##  BC  D #'--DLLIxx44V=MN9@@AQRSy)G z	!-0F U?'/L$$[1Cby+C"HI6,&wj0I;Xdfrtxyz
	Fs   >GGc                 n   t        | j                        s[d| j                  vrM| j                  j                  d      r2t        j                  j                  | j                        }|d   |d}nt        | j                        s[d| j                  vrM| j                  j                  d      r2t        j                  j                  | j                        }|d   |d}n t        t        | j                  d      \  }}}|t        d| j                  z   d	z   d
       |d   d   }|dk(  rt        |d   |d   d   |        y |dk(  rt        ||        y |dk(  rt        ||        y |dk(  rt        ||        y |dv rt        ||        y |dk(  rt        ||        y t        d|d   d   z   dz   d
       y )Nr   r  r  r  r.  r  r8  r  rQ  rR  rh  r.  rR  r   r;  recordr  r  r   r  rj  $Error: The given object is of class zK but an object of class file, record, applet, app, or workflow was expected)rr   r<  r	  r?  r  r  r  r   rz   rJ   r   rh  r  r  r  r  )r   r   r(  r6  r  entity_result_classs         r   r-  r-    s   TYYCtyy$8TYY=Q=QRX=Yxx$$TYY/#Dzt<tyy!c&:tyy?S?STe?fxx00;#Dzt<.67L7;yy@H/J+m %		14GGK'
3G<f$''
3'
3F;	  
	(=$'		(7M40		%t$	 >	>]D)	
	*]D)7-
:ST[:\\^_`a	cr   c                    | j                   D ]O  }t        t        |      \  }}}|t        d|z   dz   d       |d   d   dk7  rt        dd       t	        |      xs t        |      }|sd }nt        |      r|d   d   }|r |t        |d   d	   |      st        d
d       d}| j                  du rd}	 t        j                  |d	   |      }	 |j                  d|xs t        j                  j                        }t        |      dk(  rnO|dk(  r*t        j                  j                  j!                  |       nt        j                  j!                  |       R y #  t                Y cxY w)NrQ  rR  rh  r.  rR  r   zError: expected a file objectr6  r  z5Error: project does not contain specified file objectrbTr  )modei   rS  r   )r<  r   rz   rJ   r   r   r   unicode_textr?  rW  r%  rY  r=  r   r   bufferrb  )	r   r<  r6  r  r(  path_has_explicit_projr  r[  chunks	            r   r"  r"    sr   		 '.67Ld.S+m )D03FFJ$W-74a8 "5T!:!Ok$>O%G#J/	:G "g&9'j(A$(GQLaP $D	[[t!44@F Iw7]$++B]B]^u:?4<JJ%%++E2JJ$$U+ 
 C'L	Js   5B(E!!E0c                     | j                   dk(  r@t        j                  dg| j                  z         }| j                  |_        t        |       y t        |        y )Nr  r"  )r  r  
parse_argsrt  r  r"  r   )r   cat_argss     r   download_or_catr    sH    {{c$$eWtzz%9: $ 1 1HTNr   c                 h   t        t        | j                  d      \  }}}|t        d| j                  z   dz   d       |d   d   dvrt        d	|d   d   z   d
z   d       t	        j
                  |d   |      }d}| j                  dkD  r^	 |j                  dk(  r2	 d|_        |D ]#  }t        |       |dz  }|| j                  k(  s# n y y t        d|j                  z   dz          y y # t        $ r" t        j                  j                  d       Y y w xY w# t        $ r Y y  t                Y y xY w)Nr8  r  rQ  rR  rh  r.  rR  r   r  z) but an object of class file was expectedr  rS  r   r   i   r   zFile contains binary datazClass type z not supported for dx head)r   rz   r<  rJ   r?  rC  lines_class_read_bufsizer   UnicodeDecodeErrorr   r   rb  StopIteration)r   r6  r  r(  handlerr   r  s          r   r!  r!  !  sP   *23H3799x+Q'G[-%		14GGK$W-97-
:ST[:\\<=>?	A }T2GDGGzzA~	~~'B,3G) ' "d1"djj0!	" " 7:VVW  * BJJ$$%@AB  		Js<   D +C+ 	C+ D +(DD DD 	D1$D1c                    | j                   | j                  t        d      | j                  | j                   | _        | j                   | _        t        | j                        dkD  r<| j                  0| j                  j                  d      s| xj                  dz  c_        t        j                  | j                        }|D ]  }|| _        t        | fi |  y )NzMError: Cannot provide both the -o/--output and --path/--destination argumentsr   r  )
r  r<  r2   singlethreadmultithreadr=  rV  r  copy
upload_one)r   r   rt  r<  s       r   uploadr  A  s    {{499#8kll		KK	
  ,,,D
4==A$))"7		@R@RSV@W 			S	IIdmm$E #4"6"#r   c                    t        t        |        | j                  xr | j                   | _        | j                  kt
        j                  }t
        j                  j                  dd      }| j                  dk(  rd n(t        j                  j                  | j                        }nXt        t        | j                        \  }}}|8| j                  dk7  r)t        j                  j                  | j                        }t        j                  j                  | j                        r| j                  s&t        dj!                  | j                        d       t        j                  j#                  | j                        }|t$        v r6t'        dj!                  | j                        t(        j*                         y t$        j-                  |       t        j.                  | j                        }t1        |      d	k(  rit
        j2                  j5                  |t        j                  j7                  |t        j                  j                  | j                              d
d       y |D ]  }t9        j8                  |       }d
|_        t        j                  j7                  | j                  |      |_	        dj!                  ||t        j                  j                  | j                              |_        d
|_        t?        |        y 	 t        j@                  | j                  dk(  rd n| j                  | j                  dk(  rt(        jB                  jD                  nd | jF                  d ntI        | jF                        || jJ                  | jL                  | jN                  || jP                  | jR                  || j<                  | j                  | jT                        }| jV                  r|jY                          | j                  rt'        |j[                                y | j:                  st]        |j_                  d
d
             y y #  t                Y y xY w)Nr  r  r  zEError: {f} is a directory but the -r/--recursive option was not given)frh  zSkipping {f}: directory loopr   r   Trp  z{p}:{f}/{sf}/)pr  sf)rV  r   write_buffer_sizer;  r  r  r  r6  r  r  r  rq  show_progressr  r  )0r   r+   r  ra  r<  r?  r  ra  r-  rV  r_  rc  ry   rk  r  rJ   r  realpathupload_seen_pathsr   r   r   r   ro  r=  r  ru  rl  r  muterq  r  upload_local_filer#  r  r  intr  r  r  r  r  r  wait_wait_on_closer  r   r.  )	r   r6  r  r;  	norm_pathdir_listingr  sub_argsr[  s	            r   r  r  X  s(   $d+++>DJJDyy##c2}}+t1A1A$--1P (tyy A<DMMS077##DMM2D	ww}}T]]#~~\ccfjfsfsctvwxGG$$T]]3	))077$--7HszzZ!!),jj/{q HH''BGGLLQSQXQXQaQabfboboQp<q=A2C D ! %99T? $$&GGLL$B! / 6 6FrwwO_O_`d`m`mOn 6 o#' 8$%	++dmms>RdX\XeXeFJmmWZFZ#))2B2B`dGKG]G]GetDGH^H^D_151526**37;;4;7;48LL3948LL:>:L:L8<8H8HJF yy%%'zzfmmo&YY6??4d?ST 	Js   DQ .(Q Q&c                 Z    !"# t        t                 j                  s j                  sd _         j                  r j
                   j
                  dk7  ry t        j                  }d }d} j                  xr  j                  xs  j                  } j                  xr  j                  } j                   j                  dk(  rd|||||dd}nd|i}d } j                  r j                  n j                  dz   } j                  t        t        j                  j                    j                  ddi      }|j#                  d	d       } j                  r j                  |k7  ry  j$                  | j$                  k7  ry d }d  _        nʉ j$                  } j(                  Lt+        d
 j(                        dk(  r j(                  d
z    _        t        t,         j(                  d      \  }}	}	 j&                  L j&                  dk7  r= j&                  j/                  d      s"d j&                  j1                         z    _         j2                  rd }i d j                  d j&                  d j4                  d|d j6                  d|d j                  rdn j
                  d|d j8                  d j:                  d j<                  ddd j>                  d j@                  d jB                  rdndd jD                  d}
|d k  r j                  s|d!z   |
d"<   g   G fd#d$      fd%"  "fd&fd'}	 d(}tG        jH                         #tG        jJ                  tL              g }t        jN                  d;i |
D ]  } |d)   |d   j#                  d*            } j                  r* j                  dk(  r	|d   d	   }n|d   d+   }|#vr|d!z  }n|d!z  }|jQ                  |       |j                     jS                  |jT                         ||kD  rd} nA j                  s#|<    j                  d,k(  s|j/                  d-      s|d   d)   #|<     j                  stW        |       j                  kD  rd}tY        |d. /      d  j                   }|D ]  }|d)   }|d   j#                  d*      }t[        |         }xr |d(kD  } j                  r jQ                  |d          T j\                  r "|||       kt_        ta        i tc        |d   dd j                  |0                    nAtG        jJ                  td              i c j                  dk(  rdnd} jB                  rd1nd2!d j                  d|d jB                  rdndd|te        #jg                               i}
 j2                  s||
d<    !fd3}tW        te        #jg                                     d(kD  rt        jN                  d;i |
D ]
  } ||        ji                         D ci c]  \  }}|tY        |d4       c}}tY        #jg                         #fd5/      }|D ]  } |#|            j                  r t_        t        jj                   d67             |r<tm               1 j\                  s$ j                  st_        to        d8d9:             y y y y y c c}}w #  tq                Y y xY w)<NTr  Fjob)runInputoriginalInputr   r  r   r  r:  ior  	originJobr   r  r6  r   r.  	classnamelaunched_by
executabler   
origin_job
parent_jobr.  created_aftercreated_beforer;  r  r  r  r  include_subjobsroot_executioninclude_restartedr}  r   limitc                   2    e Zd ZddZ fdZd Zd Zd Zy)$find_executions.<locals>.ExecutionIdNc                 4    || _         ||| _        y d| _        y )Nr  r  try_num)r   r  r  s      r   r   z-find_executions.<locals>.ExecutionId.__init__  s    DG&-&97DLrDLr   c                     t        |      st        S | j                  |j                  k(  xr | j                  |j                  k(  S r  )r  NotImplementedr  r  )r   r   ExecutionIds     r   __eq__z+find_executions.<locals>.ExecutionId.__eq__  s8    e[1%%77ehh&H4<<5==+HHr   c                 D    t        | j                  | j                  f      S r  )hashr  r  r   s    r   __hash__z-find_executions.<locals>.ExecutionId.__hash__  s    $,,/00r   c                 8    d| j                   | j                  fz  S )Nz%s_%dr  r   s    r   __str__z,find_executions.<locals>.ExecutionId.__str__  s    dggt||444r   c                 8    d| j                   | j                  fz  S )Nz+ExecutionId(execution_id='%s',retry_num=%d)r  r   s    r   __repr__z-find_executions.<locals>.ExecutionId.__repr__  s    @DGGT\\CZZZr   r  )r   r   r   r   r  r  r  r  )r  s   r   r  r    s    	B	I	1	5	[r   r  c                 F    t        | |rr|d|z  z          y dz          y )N try %dr   )r   )job_idr  has_retriesr  s      r   print_briefz$find_executions.<locals>.print_brief  s)    f{?PU\Uh	G+qrnpqrr   c                 J   i d}} | ||n||    d         }t        ||          dkD  }||v }	||   j                  d      d u}
||rj                  sAj                  s5t	        ||   |	j
                  |
d      }t        j                         ||<   ||    D ](  } | ||||      \  }}|s||   j                  |       * ||fS  | ||    d   |||      S j                  rj                  ||          nOj                  r | ||       n8t	        ||   |	j
                  |
xr |      }t        j                         ||<   |j                  |i       D ]A  } |t        ||         dk(  r||   d   nd |||      \  }}|s.||   j                  |       C ||fS )Nr   r   r   outputReusedFromT)has_childrenshow_outputsis_cached_resultshow_tryas_try_group_root)r  r  r  r  )
r=  r-  r   ra  r   r  re  r  r   r>  )r  root_tryexecutions_by_parentexecution_descriptionsexecution_retriesr  root_stringexecution_idroot_has_retriesroot_has_childrenroot_has_reused_outputrtryr  r  child_execution_subtree_rootr  r   
build_treer  r  r  s                   r   r  z#find_executions.<locals>.build_tree  s;   k"4X5IO`aeOfghOij067!;(,@@!7!E!I!IJ\!]ei!iyy"<=ST`=aEVEIEVEVI_ARJN#PK )4(?(?(AD%-d3 :D!+D$8LNdfw!xJGQ[)009: [((!$(9$(?(BDXZp  sD  E  E995lCDZZh(8945KL5YBSBFBSBSF\>O>dTd	fK
 !, 7 7 9D377bI 	2O%/Y\]no~]  ZA  EF  ZF0A/0RST0U  LP0D0F0A	&C"G]
 [!((1	2 [  r   c                 Z     | d |||      \  }}|rt        t        ||   |             y y r  )r   rm   )root_idr  r  executions_retriesr  r  r  s         r   process_treez%find_executions.<locals>.process_tree'	  s7    /CE[]op
d+d4j$/0 r   r   r  r  rootExecutionanalysiszjob-c                 @    | d   d    | d   j                  dd       fS )Nr.  createdr  r   )r-  rJ  s    r   r8  z!find_executions.<locals>.<lambda>R	  s1    !J-PYBZAZ]^_i]j]n]notvw]x\x@y r   rT  )r  single_resultr  r  	masterJob	parentJobc                 $   | d   } | d   |j                  d            }|j                        s|j                  d      rdk(  r9|j                        r( |j                        |j                  d            }n* |j                        xs |j                  d            }|j                  
|   vr
|   j                  |j                         ||<   	|j                     j                  |j                         |d   dk(  r|d	   D ]x  }d|d
   v s|d
   d   | d   k7  sj
                  dk7  s|d
   d   dk(  s5|d
   d   }|
|j                     vr
|j                     j                  |       |vsq|d
   |<   z y y )Nr.  r  r  parentAnalysisr  parentJobTryrR  r	  stages	execution)r-  r  r>  r   r  r  )execution_resultexecution_descr  parent
stage_descstage_execution_idr  r   descriptionsr  r  parent_fields         r   process_execution_resultz1find_executions.<locals>.process_execution_resultx	  s   !1*!=*+;D+A>CUCUV[C\]!%%l3~7I7IJZ7[#{2~7I7I,7W!,^-?-?-M~OaOabpOq!r!,^-?-?-M-uQ_QcQcdtQu!v#.B6.JJ,V4;;LOOL-;\*!,//266|7K7KL "'*j8&4X&> [
+z+/FF:VaKbcsKt  yI  JN  yO  LO NNj8J{<ST[<\`j<j1;K1H1N.19Mloo9^^ 4\__ E L LM_ `1ECMkCZ-? @[ 9r   )reversec                 <     |    |       d            d    S )Nr  r  r   )r  r  r  r  rootss    r   r8  z!find_executions.<locals>.<lambda>	  s3    l;uT{L]^cdh^iLjkmLn3o&pqz&{%{ r   r  r   zh* More results not shown; use -n to increase number of results or --created-before to show older resultsrs  r  r   )9r   r*   origin_jobsall_jobstreesr  r?  r  rb  r   r  r  r  num_resultsr  r  job_describer-  originuserr6  rw   rz   r	  r1  all_projectsr  r   r  r  r;  tagr  
no_subjobsr  re  r  defaultdictrP  find_executionsr>  r   r  r=  rd  maxra  r   rm   r   r   r  r   r  re   rg   rJ   )$r   r6  r$  more_results
include_ioinclude_internet_usage_ipsdescribe_argsid_descjobs_to_fetchr4  queryr  num_processed_resultsexecutions_cacher  r  r  
executionsexecution_tryexecution_max_tryr  
root_fieldr  r   r   sorted_rootsr  r  r  r  r  r  r  r  r  r  s$   `                         @@@@@@@@@@r   r*  r*    sV   *D1
DKK3v8MGFL,,,499B1B1BJ!%!;$))..~~"'  :
	 z*G )-

D$$8H8H28MM ww48800$''D%=I[$/6 1;;"v'<	<<##C6"<#||c1$,-B-1\\9%F!GUE99 TYY&%8AUAUV]A^$))//"33DIG5[$.. 5DII54??5 5 djj	5
 65 T%5%564;;5 5 d005 t225 TYY5 &5 TXX5 4??5 d5 t225  !"3!5E" tDJJ&*gK[ [*s.! .!`1
 !'')'33C8 $ 4 4 =u = 	E&'7'=?OPZ?[?_?_`e?fgLzz>>U*+J7DD+J7HDu$)Q.)%*% ''(89loo.22<3G3GH$}4#zz"d>>Z/DOOF4K #3:">t"DE$K3	E6 zz#$t'7'77# 06yz  |M  }A  }M  }M  NJ$. Y /5 0 < @ @ G$'(9,(G$H!,F1BQ1F99&&'7
'CDZZmXF+b*DEUV`EaQVRVQUQbQbMU	+W X YY" 2=1H1H1NPR. ,)-5)@FVJ*.//;{L $..&d(*;ejjl!3	5E
 $$ $+i [ [< 4

%&*(,(<(<(Eu(E ?$,-=>? M^LcLcLe$fDAqQq$(?%?$f!  &JJL{ 
 ) eD t.BLRcde99$**[34MO3TZZ499$  B  VZ  [  \ LUZ3< %g
s3   #C0\ \ )\ ;G\ \1B \ \ \*c                 0   | j                   | j                  | j                  | _         n3| j                   '| j                  t        t        d      t        f       t	        t
        |        | j                  rd | _        d | _         d| _        n| j                  t        j                  | _        nt        d| j                        dk(  r| j                  dz   | _        | j                   4t        d| j                         dk7  rt        t        d      t        f       t	        t        | j                  d      \  | _        }}| j                   E| j                   j                  d      s*t	        t        | j                   d	
      \  | _        | _         }| j                  rt!        t!        dd            }n#| j"                  rd}nt!        t%                     }	 t        j&                  d"i d| j(                  d| j*                  d| j,                  d| j.                  d| j0                  d| j2                  d| j4                  d| j6                  d| j8                  d| j                  d	| j                   d| j                  s| j                  nd d| j:                  d| j<                  d| j>                  d| j@                  d| jB                  d|}| jD                  r*tG        tE        jH                  tK        |      d             y | j                  r|D ]  }tG        |d   dz   |d   z           y |D ]C  }| j"                  rtG        d        tM        |d          )tO        |d   d| j                  !       E y #  t                Y y xY w)#Nz'Cannot supply both --folder and --path.r*  Tr   r  z=Cannot supply both --project and --path PROJECTID:FOLDERPATH.r6  r  r  r  )r6  r  rQ  r  r   r  r  r;  r  typenamer  linkr  modified_aftermodified_beforer  r  r  r.  r  r   r  r   )include_folderr]  r   )(r  r<  rJ   r2   r   r*   r&  r6  r  r?  r  rw   rz   r	  ry   ra  rd  rb  r   r  r  r   r  r  r;  r  typer'  r<  	mod_after
mod_beforer  r  r  r   r   r  r   r   r   )r   r4  rh  r  rH  s        r   	find_datarC  	  sB   {{tyy4ii		 TYY%:=)RS&3%5	7 *D1		((T\\2b8<<#-DL;;"';C'MQS'S}-lm*7)9; &..C.2llI&G"eU {{t{{'='=c'B+3L$++X`+a(dk5zzT$4%@A	%9%;< (( B4>> B/3zzB48OOB 59OOB /3ii	B
 48>>B 37))B /3hhB >BYYB 26B 15B GKll$,,X\B 9=B :>B 8<7I7IB 9=8K8KB 15B  3A!B" 99$**T']156::! >fY'#-t<=> " p<<"I'z(:;#F:$6t]a]n]nop
s   D6N *N >AN Nc                 ,   t        t        |        t        t        |        t        t        |        	 t	        j
                  | j                  d| j                  | j                  | j                  rdn| j                  | j                   | j                  s| j                   nd | j                  r| j                  nd | j                  | j                  | j                  | j                  | j                         }t%        |        y #  t#                Y xY w)Nr  r  )r;  r  r  r  r   r.  r  r  r  r  r  r  externalUploadRestricted)r   r*   r<   r=   r?  r  r;  r  r'  r  r   ra  r  r  r  r  external_upload_restrictedrJ   rk   r   r  s     r   r  r  	  s    *D1%5t<$$$))v04dhh6:kkFtzz37::~LPKK_]a<@KKT[[T373E3E484G4G,0KK151A1A>B>]>]
_ g&
s   CD Dc                    t        j                  | j                  d| j                  | j                  | j
                   | j                  | j                  | j                  | j                  | j                  | j                  | j                  dd| j                  | j                   | j                   | j                  | j                   di      }| j                  r
d |D        }n|}| j                  rd |D        }|S t!        |d 	      }|S )
Nr  r:  T)r;  r<  r~  rz  	publishedr  r;  r  categoryall_versionsrI  	billed_to
created_by	developerr  r  r=  r>  r.  c              3   2   K   | ]  }|d    d   s|  yw)r.  r<  Nr   rY  rH  s     r   r[  z#find_apps_result.<locals>.<genexpr>
  s     $iPZI[\gIhV$is   c              3   *   K   | ]  }d |d    i  ywr  Nr   rQ  s     r   r[  z#find_apps_result.<locals>.<genexpr> 
  s     PFD&,'P   c                     | d   d   S rI  r   rH  s    r   r8  z"find_apps_result.<locals>.<lambda>"
  s    vjGYZ`Ga r   rT  )r?  r@  r;  rK  r   unpublishedrM  creatorrO  r  r  rA  rB  r<  ra  rb  rd  )r   raw_resultsmaybe_filtered_by_installr  s       r   find_apps_resultr[  
  s    ..dii6DMM.2hh040@0@,@+/>>,0LL+/>>/3/A/A040C0C0415+3dCG>>CG::~EIZZCG<<DHJJ6P +QRK" ~~$i+$i!$/!zzP6OP N 28abNr   c                    t        j                  | j                  d| j                  | j                  | j
                   | j                  | j                  | j                  | j                  | j                  | j                  | j                  dd| j                   | j                   | j                  | j                   di      }| j                  rd |D        }|S t        |d       }|S )	Nr  r:  T)r;  r~  rz  rI  r  rJ  c              3   *   K   | ]  }d |d    i  ywrS  r   rQ  s     r   r[  z/find_global_workflows_result.<locals>.<genexpr>7
  s     BFD&,'BrT  c                     | d   d   S rI  r   rV  s    r   r8  z.find_global_workflows_result.<locals>.<lambda>9
  s    
9KF9S r   rT  )r?  r  r;  rK  r   rW  rM  rX  rO  r  r  rA  rB  ra  rb  rd  )r   rY  r  s      r   find_global_workflows_resultr_  %
  s    ,,$))vX\XeXe.2hh040@0@,@+/>>,0LL+/>>/3/A/A040C0C0415+3dCG::~EIZZCG<<DHJJ	6P +QRK  zzBkB N *STNr   c           	      
   d }|j                   r*t        t        j                  t        |       d             y |j                  r| D ]  }t        |d           y |j
                  sk| D ]e  }t         ||      t        d      z   |d   j                  d|d   d         z   t        d	      z   |d   d   z   t        d
      z   |d   d   z          g y | D ]  }t         ||      t        d      z   |d   z   t        d      z   |d   j                  d|d   d         z   t        d	      z   |d   d   z   t        d
      z   |d   d   z   t        d	      z   |d   j                  dd      dkD  rdndz   t        d      z           y )Nc                 .    | d   d   dv r
t               S dS )Nr.  r  )zorg-dnanexuszorg-dnanexus_appsr   )rb   rV  s    r   maybe_xz#print_find_results.<locals>.maybe_x=
  s"    %j1(;?ddz|mjmmr   r  r   r  r   r.  r~  r;  r  z), vrz  rI  r   rW  r  )r   r   r  r   ra  rb  rf   r-  )r  r   rb  rH  s       r   print_find_resultsrc  <
  s   n yydjjgq12zz 	 F&,	 \\ 	UF'&/IcN2VJ5G5K5KGU[\fUghnUo5pps|  ~B  tC  C  FL  MW  FX  Y_  F`  `  cl  ms  ct  t  w}  ~H  wI  JS  wT  T  U	U  	iF'&/IcN2VD\AIcNRU[\fUgUkUklsu{  }G  vH  IO  vP  VQ  Q  T]  ^b  Tc  c  fl  mw  fx  y  f@  @  CL  MS  CT  T  W]  ^h  Wi  js  Wt  t  w@  AE  wF  F  Y_  `j  Yk  Yo  Yo  p{  }~  Y  BC  YC  JU  IV  W  Zc  dg  Zh  h  i	ir   c                 V    	 t        |       }t        ||        y #  t                Y y xY wr  )r[  rc  rJ   rG  s     r   r@  r@  M
  s'    "4(7D)
    (c                 V    	 t        |       }t        ||        y #  t                Y y xY wr  )r_  rc  rJ   rG  s     r   r  r  T
  s'    .t47D)
re  c                 v   t        |       }d| j                  vr| xj                  dz  c_        t        t        | j                  d      \  }}}	 t        j
                  j                  ||      }| j                  rt        |d          y t        t        j                  |             y #  t                Y y xY w)Nr   r6  	object_idr  r  )r8   
project_idr   rz   r?  r  rG  ra  r   r   r  rJ   )r   r  r6  r4  r  s        r   update_projectrk  [
  s    *40L $//!3$%:%)__iAGUE(())G,)W::'$- $**W%&
s   ;B* B* *B8c           
      |   dt         j                  v rddlm} g }d}| j                  D ]  }	 t	        |dd| j
                        \  }}}|t        t        d	|z   d
z                d}@|D ]\  }	 t        j                  |d   |      }	dt         j                  v rd |      d<   n|	j                          |j                  |	       ^  | j                  r|D ]  }|j                           |rt!        dd       y y #  d\  }}Y xY w# t        $ r'}
t        t        t        |
                   Y d }
~
d }
~
ww xY w)N_DX_FUSEr   )xattrFr8  Tr#  rv  rl  r$  r  rS  closedr   r   rh  )r_  r`  rn  r<  rz   r   r   rg   r?  rC  r,  r>  r  r   r  r  rJ   )r   rn  handlersrv  r<  r6  r  rg  rH  rZ  r  r  s               r   r,  r,  m
  sB   RZZHI		 .	13HRZTXRVRZRZ4\0G[. !$,t36IIJKI( 	..**6$<IC!RZZ//7dG,		OOC(	..2 yy 	%G""$	% Q -	1&0#G^ ! .$s7|,--.s$   C?/AD?D	D;D66D;c                    d}| j                   rt        | j                        dk(  rut        j                  j	                  | j                  d         rI	 t        | j                  d         j                         j                         j                  d      | _        | j                  D ]  }t        |      st        |      rGt        j                  |      }t        d|z   dz          t!        |j"                         t        d       `	 t%        |d	
      \  }}}|t        t'        d|z   dz                d}t        j                  |d   |d   d         }t        d|z   dz          t!        |j(                         t        d        |rt+        dd       y y # t        $ r"}t        d| j                  d   |fz        d }~ww xY w#  d\  }}Y xY w)NFr   r   r   z&Could not open {}. The problem was: {}zWaiting for z to finish running...Doner8  r  rv  rQ  rR  Tr  r.  r6  rS  z to close...r   rh  )	from_filer=  r<  r_  rm  r$  r%  stripr  IOErrorr   ru   rv   r?  rC  r   r   wait_on_donerz   rg   r  rJ   )	r   rv  r  r<  dxexecutionr6  r  r(  r  s	            r   r  r  
  s   I ~~#dii.A-"''..12N	NTYYq\*//1779??EDI
 		 T?nT2**40K.4'*AAB[--.&M46KD[c6d3m $d/$69LLMN 	**=+>V`HabkHlmnt+n<=//0f), Q 5  	N8DIIaL!;LLN N	N4)3&s%   AF 	G
	G%GG
Gc                    dgt         j                  dd  z   t         _        d }d }d }d }t        j                         } t        j
                  !| j                  st        j                  d       	  ||       | _        | j                   || j                        | _	        | j                   ||       | _
         ||        | j                  dv rt        j                  |        y | j                  d	v rt        j                  | t               y d
}|dz  }|dz  }t        j                  |       y # t        $ r>}t        dj!                  |      t         j"                         t%                Y d }~y d }~ww xY w)Ndx buildr	   c           
         ddddd}t        t        | ddddgdd|      \  }}}|t        d
j                  |       d       y	t	        |      dkD  rt        dj                  |       d       y	|d   d   j                  d      s|d   d   j                  d      r|d   d   S t        dj                  |       d       y	)a  
        Return source executable description when --from option is used

        Accecptable format of source_exec_path:
            - applet-ID/workflow-ID
            - project-ID-or-name:applet-ID/workflow-ID
            - project-ID-or-name:folder/path/to/exec-name
              where exec-name must be the name of only one applet or workflow

        :param source_exec_path: applet/workflow path given using --from
        :type source_exec_path: string
        :return: applet/workflow description
        :rtype: dict
        T)r  r  )r:  r  r8  Fr  r   )r   rN  expected_classesr  r  r.  Nz7Could not resolve {} to an existing applet or workflow.rh  r   zKMore than one match found for {}. Please use an applet/workflow ID instead.r   r  r.  z2Could not resolve {} to a valid applet/workflow ID)r   rz   rJ   r  r=  r	  )source_exec_pathexec_describe_fieldsr  exec_results       r   get_source_exec_descz#build.<locals>.get_source_exec_desc
  s     6:T'J[_`$%:%5.6497?6L.305.BD1k NUUVfgijkabiijz{}~1~d#..x8KN4<P<[<[\f<g"1~j11MTTUefhijr   c                    | j                   >| j                   d   j                  d      ry| j                   d   j                  d      ryt        j                  j	                  | j
                        s.t        j                  dj                  | j
                               t        j                  j                  t        j                  j                  | j
                  d            ryy)a  
        Returns an applet or a workflow mode based on whether
        the source directory contains dxapp.json or dxworkflow.json.

        If --from option is used, it will set it to:
        app if --from has been resolved to applet-xxxx
        globalworkflow if --from has been resolved to workflow-xxxx
        Note: dictionaries of regional options that can replace optionally
        ID strings will be supported in the future
        r  r  r  r   r  z{} is not a directoryzdxworkflow.json)_fromr	  r_  r<  rk  src_dirr  errorr  rf  rl  r   s    r   get_modezbuild.<locals>.get_mode
  s     ::!zz$**84D!,,Z8'ww}}T\\*LL077EF77>>"'',,t||5FGHr   c                     | j                   "| j                  t        j                  d       y | j                  }|t	        j
                         }|S )Nz8Source directory and --from cannot be specified together)r  r  build_parserr  r_  getcwd)r   r  s     r   get_validated_source_dirz'build.<locals>.get_validated_source_dir
  sF    ::!||'""#]^,,?iikGr   c                 
   | j                   dk(  r$| j                  dk7  rt        j                  d       | j                   dk(  r$| j                  dk7  rt        j                  d       | j                   dk(  r!| j                  rt        j                  d       | j
                  r!| j                  rt        j                  d       | j                  !| j                  rt        j                  d
       | j                  r0| j                  r$| j                   dk(  rt        j                  d       | j                  !| j                  rt        j                  d       | j                  !| j                  rt        j                  d       | j                  !| j                  rt        j                  d       | j                  !| j                  st        j                  d       | j                  3| j                   dk7  r$| j                   dk7  rt        j                  d       | j                  !| j                  st        j                  d       | j                   dk(  r?| j                  3| j                  d   j                  d      st        j                  d       | j                   dk(  r?| j                  3| j                  d   j                  d      st        j                  d       | j                  r!| j                  rt        j                  d       | j                   dv r!| j                   rt        j                  d       | j"                  r!| j$                  st        j                  d       | j"                  r!| j                  rt        j                  d       | j&                  r!| j                  rt        j                  d       | j(                  r!| j"                  st        j                  d       | j$                  r$| j                   dk(  rt        j                  d       | j&                  r!| j$                  st        j                  d       | j&                  rt+        j,                  d       | j                   dk(  r| j                  | j                  | j.                  | j                  | j                  | j                  | j                  | j0                  | j                  | j                  | j2                  d }t5        |j7                               D ci c]  \  }}|s	|| }}}|r4t        j                  d!j9                  d"j;                  |                   y	y	y	c c}}w )#zh
        Raises parser error (exit code 3) if there are any conflicts in the specified options.
        r  r  zB--destination cannot be used when creating an app (only an applet)r  zN--destination cannot be used when creating a global workflow (only a workflow)r  z=--region cannot be used when creating an applet (only an app)zDOptions -f/--overwrite and -a/--archive cannot be specified togetherNz8Options --dry-run and --run cannot be specified togetherz|Options --remote, --app, and --run cannot all be specified together. Try removing --run and then separately invoking dx run.z?Options --from and --ensure-upload cannot be specified togetherz@Options --from and --force-symlinks cannot be specified togetherz8Options --from and --remote cannot be specified togetherzCOptions --from and --no-parallel-build cannot be specified togetherzi--from can only be used to build an app from an applet or a global workflow from a project-based workflowz8--version must be specified when using the --from optionr  zKapp can only be built from an applet (--from should be set to an applet ID)r   zYglobalworkflow can only be built from an workflow (--from should be set to a workflow ID)z9Options --dry-run and --from cannot be specified together)r  r  r  z6Global workflows, applets and apps cannot be kept openzlRepository argument is available only when building a Nextflow pipeline. Did you mean 'dx build --nextflow'?zNextflow pipeline built from a remote Git repository is always built using the Nextflow Pipeline Importer app. This is not compatible with --remote.zNextflow pipeline built with an option to cache the docker images is always built using the Nextflow Pipeline Importer app. This is not compatible with --remote.z[Git credentials can be supplied only when building Nextflow pipeline from a Git repository.z>Building Nextflow apps is not supported. Build applet instead.zpDocker caching argument is available only when building a Nextflow pipeline. Did you mean 'dx build --nextflow'?a  WARNING: Caching the docker images (--cache-docker) makes you responsible for honoring the Intellectual Property agreements of the software within the Docker container. You are also responsible for remediating the security vulnerabilities of the Docker images of the pipeline.Also, cached images will be accessible by the users with VIEW permissions to the projects where the cached images will be stored.)--ensure-upload--force-symlinksz--[no-]publishz--[no-]dry_run--run--remote	--version	--bill-to	--archive--region--extra-argsz+Options {} are not supported with workflowsr  )r  r  r  r  r  re  archiver  dry_runremoter  ensure_uploadforce_symlinksparallel_buildversion_overrider	  	keep_open
repositorynextflowcache_dockergit_credentialsr  warningpublishr  r0   r   r   r  rl  )r   unsupported_optionsr   r   used_unsupported_optionss        r   handle_arg_conflictsz#build.<locals>.handle_arg_conflicts  s*    99$"2"2c"9cd99((T-=-=-Dop99 T[[^_>>dllef88DLLYZ88		U(:   ^  _ ::!d&8&8`a::!d&9&9ab::!dkkYZ::!$*=*=de::!tyyE'9diiK[>[   K  L::!$*?*?YZ99$**"8DAQA\A\]eAflm99((TZZ-CDJJW[L\LgLghrLsz{::$,,Z[99;;WX??4==   N  O??t{{   v  w   C  D|}==TYY%/_`T]] CD OO0 99
"#'#5#5$($7$7"&,,"&,, KK!22!\\!\\ !KK $##1$ :>>Q>W>W>Y9Z'`A^_1'`$'`'""#P$*F4995M+N$OQ () #& (as   
U))U)z[Authentication required to build an executable on the platform; please run "dx login" first)r  r  r  zSUnrecognized mode. Accepted options: --app, --applet, --workflow, --globalworkflow.zZ If not provided, an attempt is made to build either an applet or a workflow, depending onz] whether a dxapp.json or dxworkflow.json file is found in the source directory, respectively.z	Error: {}r   )r   argvr  r  r?  r  r  r  r  r  r  r   buildr   r  r   r  r   rJ   )r   r  r  r  r  r  r  s          r   r  r  
  s?   |chhqrl*CH!kF2	jQX ""$Dxy/5::!-djj9DJ 99 DIT"99))t$YY88""46gCooCrrCs# k  ##**5

s%   3A4D3 ((D3 !D3 3	E:<4E55E:c                     | D cg c]>  }|dk7  r5|j                  d      s$|j                  d      sd|j                         z   n|@ c}S c c}w )Nr,  r  r.  )r	  r1  )thingr;  s     r   process_list_of_usernamesr    s]    
 	 	 '+h&6'( djjl"    s   AAc                 b   t        t        | j                        }t        | j                        | _        	 |d   dk(  r1t
        j                  j                  |d   d| j                  i       y t
        j                  j                  |d   d| j                  i       y #  t                Y y xY wNrR  r  r  authorizedUsersr  )
r   r}   r  r  usersr?  r  app_add_authorized_users$global_workflow_add_authorized_usersrJ   r   r   s     r   	add_usersr    s    -txx8D*4::6DJ=E!HH--d4jHY[_[e[eGf-gHH99$t*TegkgqgqSr9s
   8B  /0B   B.c                 b   t        t        | j                        }t        | j                        | _        	 |d   dk(  r1t
        j                  j                  |d   d| j                  i       y t
        j                  j                  |d   d| j                  i       y #  t                Y y xY wr  )
r   r}   r  r  r  r?  r  app_remove_authorized_users'global_workflow_remove_authorized_usersrJ   r  s     r   remove_usersr    s    -txx8D*4::6DJ=E!HH00dK\^b^h^hJi0jHH<<T$ZWhjnjtjtVu<v
r  c                 f    t        t        | j                        }|d   }|D ]  }t        |        y )Nr  )r   r}   r  r   )r   r   r  r%  s       r   
list_usersr    s4    -txx8D"#E dr   c                 b   t        t        | j                        }t        | j                        | _        	 |d   dk(  r1t
        j                  j                  |d   d| j                  i       y t
        j                  j                  |d   d| j                  i       y #  t                Y y xY wNrR  r  r  
developersr  )
r   r}   r  r  r  r?  r  app_add_developersglobal_workflow_add_developersrJ   r  s     r   add_developersr    s    -txx8D/@DO=E!HH''T
,PTP_P_A`'aHH33DJl\`\k\kMl3m
r  c                 &   t        t        | j                        }	 |d   dk(  r&t        j                  j                  |d         d   }n%t        j                  j                  |d         d   }|D ]  }t        |        y #  t                Y y xY w)NrR  r  r  r  )	r   r}   r  r?  r  app_list_developersglobal_workflow_list_developersr   rJ   )r   r   r  ds       r   list_developersr    s    -txx8D	=E!55d4jA,OJAA$t*Ml[J 	A!H	
s   A%B Bc                 d    t         j                   j                  | dz        j                  d      S )Nr}  z%Y-%m-%d %H:%M:%S)r  r  strftime)epochSecondss    r   render_timestampr    s*    **<+=>GGH[\\r   c                    	 t        | j                        r2t        j                  j	                  | j                        }|d   |d}n t        t        | j                  d      \  }}}|t        d| j                  z   dz   d       n|d   d	   }|d
k7  rt        d|z   dz   d       t        j                  j                  |d   | j                  | j                  | j                  d      }|d   D ]  }|d   dk7  rt        |d         nd}| j                  dk(  r7t        dj                  |t!        d      |d   t!        d      |d                at        dj                  |j#                  d      t!        d      t%        |d         j#                  d      t!        d      |d                 y #  t                Y y xY w)Nr  r  r8  r  rQ  rR  rh  r.  rR  rj  r  z- but an object of class database was expected)r  r  r  r  r  modifiedr   r   Tz
{}{}{}{}{},sizer<     r      )rr   rj  r?  r  database_describer   rz   rJ   r  r  r  r  r  csvr   r  rf   rjustr   )	r   r   r(  r6  r  r  r  r  date_strs	            r   list_database_filesr    s   !T]]#88--dmm<D#':4@M 3;;P;?==DL3N/G[-
  )DMM9<OOQRS #0
";G"D"j0?BUU@ABCE ((//$$(KKDLLUYUaUab 0 d # 	nA:;J-1:L'*6RTHD l))inai36T U l))NN2&	#AfI8L8LR8PR[\_R`bcdjbkm n	n
s   F0F3 3Gc                 b   t        t        | j                        }t        | j                        | _        	 |d   dk(  r1t
        j                  j                  |d   d| j                  i       y t
        j                  j                  |d   d| j                  i       y #  t                Y y xY wr  )
r   r}   r  r  r  r?  r  app_remove_developers!global_workflow_remove_developersrJ   r  s     r   remove_developersr    s    -txx8D/@DO=E!HH**4:\SWSbSbDc*dHH66tDzQ]_c_n_nPo6p
r  c                     t        t        | j                        }	 t        j                  j                  |d          t        d|d   z   dz          y #  t                Y y xY w)Nr  zInstalled the r;  z app)r   r|   r  r?  r  app_installr   rJ   )r   app_descs     r   r8  r8    sQ    TXX.HXd^,&!11F:;
s   6A A!c                 .   t        | j                        }|r(t        t        j                  j
                  |d          y t        j                  j                  t        j                         dddii      }| j                  |d   v rd| j                  z   | _        | j                  j                  d      rTt        t        j                  j
                  | j                         t        dj                  | j                               y t        dd	       y )
Nr  r:  r  Tr  zUninstalled the {app} app)r  zCould not find the apprh  )r{   r  r   r?  r  app_uninstallr   r  r	  r   r  rJ   )r   r  	user_datas      r   r9  r9    s     *H''$8HH**4;;=8oW[E\:]^	88y11(DH88v&TXX++TXX6-444BC-q1r   c                 R   t        t        ||| j                        }| j                  9| j                  -|j                  | j                  j                  di       d       ||j                  |d       | j                  du }t        |j                  | |       |j                  S )zL
    Returns an input dictionary that can be passed to executable.run()
    )input_name_prefixactive_regionNr  F)strip_prefix)r   r>   r  r"  rV  r   cloned_job_descr-  	batch_tsvupdate_from_argsr  )r   r  preset_inputsr  exec_inputsrequire_all_inputss         r   _get_input_for_runr    s     +%->)-6K 4==#8 	4//33JCRWX  =u= ..D0[))41CDr   c                    | j                   s?t                t        d       t        t        j                  |d             t                | j                  r(t
        r"t        dd      st        j                  d       | j                   s6t        t        d|j                         z   d	z   |z   d
z   |z   d      dz          	  |j                  |fi |}| j                   s8t        |j                  j                         dz   |j                         z          nt        |j                                t        j                  j!                          | j"                  r|j%                          nz| j                  rnt
        rh| j&                  s\| j(                  sPt+        |t,        j.                        r6t1        d      }t3        |      dk(  s|j5                         d   dk(  rd| _        t+        |t,        j.                        r| j&                  rSt        j7                  d|j                         g      }t        d       t        d       t        d       t'        |       |S | j(                  rp| j8                  r2t        j7                  dd| j8                  |j                         g      }	n%t        j7                  d|j                         g      }	t)        |	d       |S # t:        $ rS}
|j=                  d      r;t>        j@                  j=                  d      dk(  rd|
jB                  v rt        d       |
d }
~
wtD        $ r tG                Y S w xY w)NzUsing input JSON:r  r   .Confirm running the executable with this inputTr  r   Calling  with output destination r   rs  r  r   z ID: zWatch launched job now? [Y/n] r  watchr   zJob Logz-------ssh--ssh-proxy)ssh_config_verifieddetachDX_RUN_DETACH1detachedJobzUnable to start detached job in given project. To disable running jobs as detached by default, please unset the environment variable DX_RUN_DETACH ('unset DX_RUN_DETACH'))$ra  r   r   r  r  r   r   r  r  rg   r  r  r  
capitalizer   r   flushr  rv  r  r  r  r?  DXJobr   r=  r1  r  	ssh_proxyr   r-  r_  r`  r  r  rJ   )r   r  r  r  r"  
run_kwargsrw  answer
watch_argsssh_argsr  s              r   run_oner  6  s   ::!"djjA./ ||MW[\KKN::d:
 1 1 336QQT]]`ccfoo%)+-12 	3#$jnnZ>:>zz+$$//1G;k>P>P>RRS+$$&'

99$$&\\otzzTXXS]^ikokukuSv;<F6{a6<<>!#4#;!
k4::.zz#..9K9K9M/NO
b	i i j!   >>%00t~~{?Q?Q?ST VH  &00%9K9K9M1NOHH$7   >>(#

(G3(NS`dedidiSi P Q 
s'   FK !A<K 	M(AL66MMc                 &   | j                   s0| j                  s$| j                  s| j                  s| j                  rt        d      t        ||| j                        }| j                  s?t        d       |d   D ]"  }t        t        j                  |d             $ t                | j                  r(t        r"t        dd      st        j!                  d	       | j                  s6t        t#        d
|j%                         z   dz   |z   dz   |z   d      dz          t'        |||| j(                        }|D 	cg c]  }	|	j%                          }
}	t        dj+                  |
             t,        j.                  j1                          y c c}	w )NzMOptions {wait, watch, ssh, ssh_proxy, clone} do not work with batch executionz-Batch run, calling executable with arguments:launch_argsr  r   r  Tr  r   r  r  r   rs  r  r   r  )r  r  r  r  cloner  rV   r  ra  r   r   r  r  r   r   r  r  rg   r  rU   batch_foldersrl  r   r   r  )r   r  r  r  r"  r  b_argsr  dx_execsdxeexec_idss              r   run_batch_all_stepsr  q  sA   		



ghhz:t~~FF::=>& 	+A$**Qq)*	+ ||MW[\KKN::d:
 1 1 336QQT]]`ccfoo%)+-12 	3 VZ9K9KLH(01

1H1	#((8
JJ 2s   <Fc                   %& t        | ||      }i i i }	}}d }
| j                  rt        j                  | j                        j	                  di       }t        j                  |d      }t        j                  |d      }t        j                  |d      }t        j                  |d      }t        j                  |d      }| j                  j	                  di       xs i }n>i }t        i       t        i       t        i       t        i       t        i       f\  }}}}}i }| j                  rkt        j                  | j                        }t        | j                  t              s4t        t        |j                         |j                                     }n|}| j                  r/|j                         r|j                         st        d	      t        j                  | j                        }|j!                         }
t        j                  |
j	                  d
i       j	                  di       d      }t        | j                  t              sr|j                         rbt        t        |j                         |j                                     }t        t        |j                         |j                                     }|j#                  |      }n|}|}|}||z   |z   |z   j                         }| j                  r|rt%        d      dj'                  | j                        z   }|dj'                  | j                  j	                  d      t)        j*                  |            z  }| j,                  r1|dj'                  t)        j*                  | j,                              z  }t/        t1        |             t/                | j,                  rr| j,                  j3                         D ci c])  \  }}|t        j                  |      j                         + }	}}t        t        ||	            j                         }	n|}	| j4                  rd| j4                  v r	g d| _        d }| j6                  rd}n| j8                  d| j8                  i}i d|d|d| j:                  d| j<                  d| j>                  d| j@                  d| jB                  xs d d| jD                  d| jF                  xs d d| jH                  xs d d| j4                  rd| j4                  ind d| jJ                  d | jL                  d!|xs d d"|	xs d d#d d$d d d | jN                  | jP                  | jR                  | jT                  | jV                  | jX                  | jZ                  | j\                  rt_        | j\                        d%z  nd | j`                  rt_        | j`                        d%z  nd || jb                  d&}t        |td        jf                        st        |td        jh                        r| jj                  |d'<   tm        | jn                  xs | jp                  xs | jD                  g      rU|d    d(v rI| jr                  sBt/        t1        t%        d      d)z   t%        |d          z   d*z                t/                nd+|d <   |d    d(v r| jr                  stu               %|
xs |j!                         }g d,&%&fd-}t        |td        jv                        r:|d.   D ]1  }te        j                   |d/         } ||j	                  d0             3 n ||j	                  d0             %rft/        t1        t%        d      d)z   t%        |d          z   d1z   d2z   d3z   d4jy                  t{        %            z   d5z   d6z   d7z                t/                | jr                  st        |td        jv                        r	 td        j|                  j                  |j                          |j                  |fi |      } t        | d.   D !cg c]  }!d8|!d9   v r|!d9   d8   | d   k7  r|! c}!      }"|"d:kD  rt/        t1        d;t        |"      z   d<z                t        | d.         D ]P  \  }#}!d8|!d9   v s|!d9   d8   | d   k7  s|!d9   d   }$t/        d=t        |#      z   d>z   |$z   d?z   |!d9   d   z   d@z          R t/                | j                  t        | |||||       y t        | |||||       y c c}}w c c}!w # t        $ r Y Dw xY w)ANsystemRequirementsinstanceType)_typeinstanceTypeSelectorclusterSpec
fpgaDrivernvidiaDriverr   zCannot specify --instance-count when cloning a job that uses instanceTypeSelector without providing --instance-type. instanceTypeSelector and clusterSpec are mutually exclusive.runSpecWARNINGz4: --instance-type argument: {} may get overridden byz, {} mergedSystemRequirementsByExecutable: {}r  z7 and runtime --instance-type-by-executable argument:{}
All)AppErrorAppInternalErrorAppInsufficientResourceErrorExecutionErrorTr  r6  r;  r  r  r  
depends_on	allow_sshignore_reuseignore_reuse_stagesr  debugOndelay_workspace_destructionprioritysystem_requirements!system_requirements_by_executableinstance_typecluster_specr}  )fpga_drivernvidia_driverstage_instance_typesstage_foldersrerun_stagesr  
cost_limitrankdetailed_job_metricsmax_tree_spot_wait_timemax_job_spot_wait_timepreserve_job_outputsr0   head_job_on_demand)lownormalz,: You have requested that jobs be run under z\ priority, which may cause them to be restarted at any point, interrupting interactive work.high)UPLOADr  
ADMINISTERc                    | sy | j                  d      rj                  d       | j                  d      rj                  d       | j                  d      v s| j                  d      v rj                  d       y y )NrO  zaccess to apps as a developernetworkzInternet accessr6  allProjectsz$write access to one or more projects)r-  r   )access_specspecial_accesswrite_permss    r   check_for_special_accessz*run_body.<locals>.check_for_special_access-  su    {+""#BCy)""#45y)[8}-<""#IJ =r   r  r  accesszB priority, which may cause them to be restarted at any point, but z)the executable you are trying to run has zrequested extra permissions (r  z).  zHUnexpected side effects or failures may occur if the executable has not z+been written to behave well when restarted.r  r  r   zThe following z6 stage(s) will reuse results from a previous analysis:z  Stage r  r  r  )Ir  r  r  deepcopyr-  r   from_sys_requirementsr  from_instance_typer  r   rT   as_dictinstance_countr   from_instance_countr.  override_cluster_specr_   r  r   r  instance_type_by_executabler   rg   r   debug_onr)  preserve_job_outputs_folderr;  r  r  r  r  r  r  r  r  r  r!  r"  r#  r  r$  r%  r&  r'  rR   r(  r0   r?  r}  r  r*  r=  r  r  ra  rP  r  rl  rd  r  workflow_dry_runr  _get_run_inputr=  r   	enumeraterL   r  r  r  )'r   r  r  r  r  r  r"  requested_instance_typerequested_cluster_spec+requested_system_requirements_by_executableexecutable_describecloned_system_requirementscloned_instance_typecloned_instance_type_selectorcloned_cluster_speccloned_fpga_drivercloned_nvidia_driver(cloned_system_requirements_by_executablerequested_instance_countcluster_spec_to_overriderequested_fpga_driverrequested_nvidia_driverrequested_system_requirementsr  r   sys_req_by_execr)  r  executable_descr6  r  stage_exec_descr  stagenum_cached_stagesi
stage_namer4  r5  s'                                        @@r   run_bodyr\    sD
   #D*mDJcegikm5`3 &*]]43G3G%H%L%LMace%f"5KKLfn|}(>(T(TUo  xN  )O%4JJKemz{3IIJdlxy5KKLfn|}373G3G3K3KLrtv3w3}{}0%'""2&(>r(BDZ[]D^`vwy`z  }S  TV  }W~Xz;=PRdfz350  #9"K"KDL^L^"_$,,j9&<UCWC_C_Cacz  dC  dC  dE  >F  'G# #7 
 )002;R;Z;Z;\ ~   $:#M#MdNaNa#b (113#9#O#OPcPgPghqrtPuPyPy  {O  QS  QT  [h  $i $--z:"**,+A%H[HcHcHeg  hH  hH  hJ  CK  ,L(+A%H`HhHhHjl  mH  mH  mJ  CK  ,L(!9!O!OPh!i!4 /2 &=?U%UXm%m%<&=>Egi " 	Gy/$Z$a$abfbtbt$uuAHHI]I]IaIabfIgimisis  u]  j^  _  	_,,QXXY]YcYcdh  eE  eE  ZF  G  GGd7m
 '''+'G'G'M'M'O7Q#dO 8<=S=f=fgv=w== >
 8
 7Q3 7Q6LU46aNc 7ddkdkdm 	4 7_3 }}DMM!nDM  #		)	)	5 ($*J*JK9) 			 				
 	doo 	4<< 	doo- 	T^^ 	))1T 	t77?4 	t}})T]]+$ 	&t'G'G 	DMM 	<D 	,-X-`\`  	!" 	#$  $ 9 9++))++oo		 $ 9 9^b^z^z#6t7S7S#TVZ#Z  AE\`\w\w"5d6Q6Q"RTX"X  ~B 4oo=JB *dmm,
:tzz0R+/+B+B
'(
DJJ4$((4dnn56j!%66::d4	?-[[Z
345vw x y %+Jz"*!224::-F1D1D1F<		K j$//2-h7 H
"&--
<0H"I()<)<X)FGH %_%8%8%BC$tI)WWJz234[\ CC 7	7 :>6.CY9Z	[ ^d	d
 bb EE F G G::j$//2((33J4E4E4G4MJ4M4Mj4g\f4gi %(GH<M )`5)9U;=O)O).{);<L)MQXY]Q^)^ */ )` %a! %q($/#6G2HH  LD   D  E  F$-gh.?$@ I5+u[/AA -.>?74=P).{);F)CJ!*s1v"5"<z"I"&#').{);D)A#BDG#H I	I G ~~j)Y
JOD*iJPZ[{7QR)`   s9   3.d:	Ae e 2A
e =e A e  e 	eer   c                 
   | dk(  rt         d   j                          nd| z   |dnd|z   z   }t        t        | |      }t	        |t
        j                  j                        }t	        |t
        j                  j                        }|j                         }|rt
        j                  }|st        t        d             t
        j                  j                  |ddd	ii
      d   }||d   vrPt        t        ddj                  dj!                  t#        |d   j%                                           z                |j'                  ||      }|dz  }|r!|t)        d      z  }|j+                  dd      }	nU|r!|t)        d      z  }|j+                  dd      }	n2|t)        |d   j-                         dz         z  }|j/                         }	t	        |	t0              r|	j+                  dg       ng }
||j+                  d|d         dz   z  }|s|rP|t)        d      z  }||j+                  d      z  }t3        |j+                  dd            dkD  r|dz  }n|dz  }|dz  }|j+                  dd      xs d}|dk7  r|t5        |      dz   z  }|r|d |d   z   dz   z  }|t)        d!      z  }d"}|j+                  d#      d$|v rg }|j+                  d#      |d#   }n	d$|v r|d$   }t7        |      d%k(  r|d&z  }nWt#        t9        |      j;                               D ]  \  }}||d't)        |      z   z  }|D ]  }d(}|t=        |j+                  d)|d               dz   z  }|t?        |d	*      d+z   z  }|j+                  d,d      }g }d-|v r"|jA                  tC        d.|d-   |d                |dk7  r|jA                  t5        |d/d/0             |j+                  d1      r"|jA                  tC        d2|d1   |d                |dj!                  |      |rd+ndz   z  }|d   |
v r||z  }||z  }  t7        |
      d%kD  r|d+|z   z  }n|d3z  }|d+z  }|t)        d4      z  }|j+                  d5      d6|v rg }|j+                  d5      |d5   }n	d6|v r|d6   }t7        |      d%k(  r|d&z  }ns|D ]h  }|d(z  }|t=        |j+                  d)|d               dz   z  }|t?        |      d+z   z  }|j+                  d,d      }|dk7  sU|t5        |d/d/0      d+z   z  }j n|d3z  }tE        |       tF        jI                  d%       y )7Nr   r  zusage: dx run z	 --alias zGA project must be selected. You can use "dx select" to select a projectr+  r:  r  Tr  regionalOptionszThe global workflow is not enabled in the current region. Please run "dx select" to set the working project from one of the regions zthe workflow is enabled in: {}r  z [-iINPUT_NAME=VALUE ...]

zApp: r  zGlobal workflow: rR  r  advancedInputsr~  r;  

z	Version: rz  rI  r  z (published)z (unpublished)summaryzKSee the app page for more information:
  https://platform.dnanexus.com/app/zInputs:zAdvanced Inputs:r  	inputSpecr   z <none>
z
 
  label)app_help_versionr   helpr   zChoices:z        initial_indentr  suggestionszSuggestions:z no specification providedzOutputs:outputs
outputSpec)%
parser_map
print_helpr   r~   r  r?  bindingsr  r  r.  r  rJ   r   r  r  r  rl  r   r  append_underlying_workflow_descr_   r-  r  r'  rd  r  rg   r=  rQ   r   r^   r   r>  r?   rj   r  r  )r  alias	exec_helpr  is_appis_global_workflow	exec_desccurrent_projectcurrent_regionexec_detailsadvanced_inputsrb  advanced_inputs_help
input_specgroupparamsparamparam_string
helpstringstanzasoutput_specs                        r   print_run_helpr  h  s   R5$$&$z15=Rk\aNab	+Z?GT]]%8%89'1O1OP$$&	"//O":]$_ `!XX66EMPXZ^O_D` 7 bbjlNY/@%AA:a4;;xxY/@%A%F%F%H IJLL$   ??	>ZI44	g&I$==B7L122I$==B7Li0;;=DEEI"..0LDN|]aDb,**+;R@hjY]]7If,=>GG	'k**Iy11I9==b12R7^+	--	I--	2.4"b=g//I gjstzj{{  ~D  D  DIT)_$	1==".+2JJ}}X&2&x0
	)&{3
:!#[(	%)*>z*J*P*P*R%S 6ME6(!UT%[%88	!' 6'-$	%))GU6]2S(TW[([[$ED(QTX(XX%*YYvr%:
"$$-#NN+HINyIYINw,Y Z &+#NN4
:is+tu 99]3#NN+HIN}I]INw,Y Z %G(<UW(XX =O;0L@0%5I1668 '!+(<!<<I55IT	T*%%	==#/<93LK}}Y'3'	2*'5;1$[(	( OE'I599WeFm+L!MPT!TTIU!3d!::I!&62!6J!R'!T*9C<F&HJN&O O	O 55Ii
KKNr   c            	      t   t        d       t        t        d             t        d       t        dt        dt        d      z   dz   t        d      z   d	z   d
d
      z          t        d       t        t        dd
d
             t        dt        t        d      dz   d
d
      z          t        d       t        t        dt        d      z   dz   d
d
             t        d       t        t        dt        d      z   dz   d
d
             t        d       t        t        d             t        t        dt        d      z   dz   d
d
             t        d       t        t        dt        d       z   d!z   t        d"      z   d#z   t        d      z   d$z   d
d
      dz          t        j	                  d%       y )&Nz"Help: Specifying input for dx run
zWThere are several ways to specify inputs.  In decreasing order of precedence, they are:a  
  1) inputs given in the interactive mode
  2) inputs listed individually with the -i/--input command line argument
  3) JSON given in --input-json
  4) JSON given in --input-json-file
  5) if cloning a job with --clone, the input that the job was run with
     (this will get overridden completely if -j/--input-json or
      -f/--input-json-file are provided)
  6) default values set in a workflow or an executable's input spec
zSPECIFYING INPUTS BY NAME

z7Use the -i/--input flag to specify each input field by r;  z and r  r  rs  rh  z
    Syntax :  -i<input name>=<input value>
    Example:  dx run myApp -inum=34 -istr=ABC -ifiles=reads1.fq.gz -ifiles=reads2.fq.gz
a9  The example above runs an app called "myApp" with 3 inputs called num (class int), str (class string), and files (class array:file).  (For this method to work, the app must have an input spec so inputs can be interpreted correctly.)  The same input field can be used multiple times if the input class is an array.r   zJob-based object referencesz> can also be provided using the <job id>:<output name> syntax:z|
    Syntax :  -i<input name>=<job id>:<output name>
    Example:  dx run mapper -ireads=job-B0fbxvGY00j9jqGQvj8Q0001:reads
zYou can z%extract an element of an array outputz3 using the <job id>:<output name>.<element> syntax:z
    Syntax :  -i<input name>=<job id>:<output name>.<element>
    Example:  dx run mapper -ireadsfile=job-B0fbxvGY00j9jqGQvj8Q0001:reads.1
              # Extracts second element of array output
zWhen executing 	workflowszR, stage inputs can be specified using the <stage key>.<input name>=<value> syntax:zs
    Syntax :  -i<stage key>.<input name>=<input value>
    Example:  dx run my_workflow -i0.reads="My reads file"
z<stage key> may be either the ID of the stage, name of the stage, or the number of the stage in the workflow (0 indicates first stage)zIf the r   z has explicit, workflow-level inputs, input values must be passed to these workflow-level input fields using the <workflow input name>=<value> syntax:z
    Syntax :  -i<workflow input name>=<input value>
    Example:  dx run my_workflow -ireads="My reads file"

SPECIFYING JSON INPUT
zjJSON input can be used directly using the -j/--input-json or -f/--input-json-file flags.  When running an r  r  r  zR, the keys should be the input field names for the app or applet.  When running a z, the keys should be the input field names for each stage, prefixed by the stage key and a period, e.g. "my_stage.reads" for the "reads" input of stage "my_stage".r   )r   rg   r_   r  r  r   r   r   print_run_input_helpr    s   	
/0	$h
ij	 	 	 

)D1jmqrxmy1y  }D  2D  GK  LS  GT  2T  WZ  2Z  ko  CG  -H  H  I	   
$  K  \`  tx  y  z	$d89<||  NR  fj  k  k  l	   
$zD!HIIDE"d< = 
  
 
$ 4#44  8L  L  ]a  uy  z  {	  
 
$  X  Y  Z	$y4
++  /G  G  X\  pt  u  v	   
${  C  DI  J  J  MS  S  VZ  [c  Vd  d  g{  {  ~B  CM  ~N  N  Qv  v  GK  _c  d  gk  k  l
KKNr   c           	         | j                   r t        | j                  | j                         d }| j                  et        d | j                  D              rIt        t        d | j                              | _        t               }| j                  j                  |       | j                  6| j                  s| j                  r| j                  st               }|g| _        | j                  r!| j                  st        t        d             | j                  r4| j                  j                  | j                  j                  d             | j                  s| j                  s| j                  r
t!                | j"                  s6|4t%        dj'                  |dj)                  | j                                     t+        t,        |        t+        t.        |        | j0                  <| j                  dk(  r-t        t2        d   j5                         t7        d	      z   d
       d\  }}| j8                  9| j:                  t        t        d             t=        | j8                  dd      }| j:                   t+        t>        | j:                  d      \  }}}| j@                  s| jB                  rbi }| j@                  D ]   \  }}t+        t>        |d      \  }}}|||<   " | jB                  D ]  \  }}|jE                  d      ||<    |r|| _#        d }	i | _$        | j0                  }tK        | j0                        stM        | j0                        r3tN        jP                  jS                  | j0                  dddddd      }	nog }
d| j0                  v r| j0                  jU                  d      }	 t=        | j0                  d |       }|q| j0                  |dz   d  }tK        |      stM        |      r tN        jP                  jS                  |      }	n)|
j                  tO        jV                  |ddi|             |	tN        jX                  B	 |
j                  tO        jZ                  | j0                  dditN        jX                               dd l.}t_         |j`                  |
 d       }|dk(  rt        dd       n4|dk(  rt        dd       n"tN        jP                  jS                  |d         }	| j:                  |xs |	d   }|	d   }| jb                  3te        jf                  d |	d!         }||	d!   d"z   | _1        n
|	d!   | _1        d#D ]+  }ti        | |      tk        | ||	jm                  |             - |	d$   d%k(  r|	| _$        | j                  dk(  r'|	jm                  d&|	jm                  d'd            | _        | jn                  d(|	d   |	jm                  d&|	jm                  d'd            |	d   |	d   |	d!   |	d)   |	d*   d+i| _7        n| j                  dk7  rTd,j'                  | j                        }|d-j'                  | j0                        z  }t        tq        |      tp        f.       tN        jP                  js                  |d|	d   idd/      d   | _        t+        tt        | j                  | j                        }tw        |tN        jx                        }tw        |tN        jz                        }| j|                  r|s|rt        tq        d0      tp        f.       | j~                  r|s|rt        tq        d1      tp        f.       |'tN        jX                  }|t        t        d2             d | _@        |r-tN        jP                  j                  |d3d4dii5      d4   | _@        | j                  s't        j                  jm                  d6      d7k(  | _B        |1|rti        |d8d       }| tN        j                  jm                  d9d      }t        | |xs |       t+        t        |        | j                  r$|s|rt        t        d:             t        |        t        | |||       y #  Y AxY w#  Y xY w);Nc              3   $   K   | ]  }|d u  
 y wr  r   )rY  ips     r   r[  zrun.<locals>.<genexpr>&  s     3brTz3s   z4Option --ssh-proxy cannot be specified without --sshr^  r   ztDetected client IP as '{}'. Setting allowed IP ranges to '{}'. To change the permitted IP addresses use --allow-ssh.r  r   r  znError: Either the executable must be specified, or --clone must be used to indicate a job or analysis to cloner	   rv  zOptions --project and --folder/--destination cannot be specified together.
If specifying both a project and a folder, please include them in the --folder option.TF)is_errorr  r  r  r  )r   r   r   r  r   r  )r;  r.  r6  r   c                 $    t        | d   dd      S )Nr.  FT)r  r  )r   rV  s    r   r8  zrun.<locals>.<lambda>  s    7QRXYcRd_d`d8f r   z
none foundz[dx run --clone: No matching execution found. Please use a valid job or analysis name or ID.rh  znone pickedr  r6  z\(re-run\)$r;  z	 (re-run))r  r  r  rR  r  r  r  
clonedFromr  r  )r  r  r6  r  r;  r  r  zaWorkflow executable ("{}") cannot be provided when re-running an analysis with 'dx run --clone'. zrYou can instead run 'dx run --clone {}', with other optional CLI arguments, to re-run the previously run analysis.r*  )r6  initializeFrom	temporaryz:-d/--depends-on cannot be supplied when running workflows.z:--head-job-on-demand cannot be used when running workflowszyUnable to find project to run the app in. Please run "dx select" to set the working project, or use --folder=project:pathr:  r  r  r  r  outputFolderr  z/--instance-count is not supported for workflows)Krg  r  r  rq  r  r=  r   filterget_client_ipr>  r  r@  r  rJ   r   r  verify_ssh_configra  r   r  rl  r   r1   r(   r  rm  r  rg   r6  r  rx   rz   stage_output_folderstage_relative_output_folderlstripr"  r  ru   rv   r?  r  r#  r   r*  r  	find_jobs	itertoolsrq   chainr;  rX  searchgetattrsetattrr-  r  r2   workflow_newr~   r  r  r  r  r*  r  r  r  r_  r`  ra  r5   r6   r<  r7   r\  )r   	client_ipr  r  r4  r"  rX  stage_folder_proj
clone_desc	iterators	colon_posr  execution_name_or_idr  result_choice	match_objr   
error_mesgr  is_workflowrt  s                         r   r  r     s0   yyt

3I~~!3DNN33!&t~~">?DN%INN!!),~~DHHt~~!O	#~~dhh:&\]^~~dnn226:;xx4>>T]]::)/  E  L  L  MV  X\  Xa  Xa  bf  bp  bp  Xq  r  	s&$d+zzdoo3E"..0  G  HH JK	L &Iy||;;"z u   1TYZ	{{&./D/3{{8@'B#	9e 4#D#D#'#;#; 	0E<)12G2>;C*E&E< $0M% 		0
 $(#D#D 	<E<#/#6#6s#;M% 	<!.DJDzzTZZ N4::$>..tzzT`dlposGu<v wJ Idjj  JJOOC0	 ;4::jy;QRG*/3zz)a-./I,$%9:nMa>b)-)>)>?S)TJ%,,T-A-AG[LPRW=JQ.S T !$$0!((TZZBF@D@Q@Q*S T
 ! 1/)//92M4f!h
 !L0z|}~"m3RO!%!6!6}T7J!KJ;;!:Z	%:I"8,I 99		-F1CDI &v.<	&v.	8 	BHtX&.h
x(@A	B g%'#-D "$",..:>>%QS;T"U||# (.&0nnXz~~eUW?X&Y#-i#8",X"6 *6 2$.z$:.89M.N#
  "$ C  J  J  KO  KZ  KZ  [
  S  Z  Z  [_  [e  [e  f  f
=#<.;-=? #hh33	HLjY]N^G_BF5H IIMODO '$**EGWdoo6K#GT-B-BCK+==)ef&3%5	7K3E=)ef&3%5	7
 %%	zb   DKhh//	>FSWHX=Y 0 [[ce;;jjnn_5<
 >IS9IdK$E3EF4d; ,zA   	#4(T7Iy1qs   6Ba= Ab =bb
c                     | j                   D ]"  }	 t        j                  j                  |       $ y #  t	                Y 4xY wr  )jobidr?  r  job_terminaterJ   )r   r  s     r   	terminater    s8     	HH""5)	Js	   3Ac                 Z	    dt               dfdt               dfdt               dff}|D ci c]  }|d   D ]  }||d   
  c}}|D ci c]  }|d   D ]  }||d   
  c}} fd	}d } j                  r d
 j                  v r j                  dk(  rd}nn j                  dk(  r@ j                  r#d
 j                  vrt        t        d              |g d      }|r$d|f}n j                  dk(  r |g d      }|rd|f}|rt        t        d|z               fd j                  d u}d\  } j                  rdg _        d _	        d _
        n j                  rdg _        d _	        d _
        nĉ j                  rddg _        d _	        d _
        n j                  dk(  rd
g _        d _	        d _
        d _        ns j                  g j                  r't        d|rdndz   d z         d!z   t!               z   d"z   nt        d#      d!z   t!               z   d"z    j"                  rd$z   fd%}dd&lm}	m}
  j*                   j,                   j.                  d'}|r j                  |d(<   t1        j2                  d) j4                        st         j4                  d*z          t7        j8                   j4                        } j                  dk(  rC|d+   d,v r<d _         j                  r)d
 j                  v r j                  j;                  d
       d-|v r3|d-   .|d-    _         j                  st=        d. j4                  z          j                  r j                  |d/<    j                  dk(  rd|d0<   n j                  dk(  rd|d1<   nd2|d1<   	  j                  dk(  r |
 |       y  |	 j4                   j                  || j                   j                  3       j                  sMt=        d4 j4                  |rd5 j                  z  ndz    j,                  rd6ndd7t>        j@                  8       jC                          y c c}}w c c}}w # tD        $ r(}t        tG        tI        |            d       Y d }~y d }~ww xY w)9N)EMERGALERTCRITICALERRORr	   )r  STDERRrh  )NOTICEINFODEBUGSTDOUTMETRICSr  r   r   c                     t        d |       D ]>  \  }}t        |      t        j                  |      k7  s)d|j	                  dd      z   c S  y )Nc                 .    t        | t              r| S | | fS r  )r  tuple)args    r   r8  z9watch.<locals>.check_args_compatibility.<locals>.<lambda>  s    *S%2H3 sTWj r   z--r  r  )r>  r  parser_watchget_defaultr=  )incompatible_listadestaargr   s      r   check_args_compatibilityz'watch.<locals>.check_args_compatibility   sO    XZkl 	7KE4tU#|'?'?'FFt||C566	7r   r  r  )z--levels METRICSz--metrics nonetopz;'--metrics' is specified, but METRICS level is not includedr^  )
get_stdout
get_stderrget_streams)tailzno-waitr  num_recent_messagesz--metrics topr  )	r  r  r  r  r  levels)
timestampsno_timestampsjob_idsr  z--metrics csvz"Can not specify both '%s' and '%s'c                 z   t        t        j                  j                  |j                  dd      dz              |d<   j                  |j                  dd      d      |d<   j                  |j                  dd      d      |d<   |d   | j                  v r| j                  |d      d	   |d
<   y |d   |d
<   y )N	timestampr   r}  r   r   level_colorlevel_color_cursesr  r;  job_name)r   r  r  r-  	seen_jobs)
log_clientr  level_colorslevel_colors_cursess     r   
enrich_msgzwatch.<locals>.enrich_msg  s    "8#4#4#B#B7;;{\]C^`dCd#ef!-!1!1'++gr2JB!O(;(?(?GUW@XZ[(\$%NUV[n`j`t`tNtj2275>B6J
  {B  CH  {I
r   rv  r  z{msg}Fr  Tz{job_name} ({job}z try {jobTry}r   r  z {level_color}{level}z {msg}z
{job_name}z{timestamp} c                 N     |        t         j                  di |        y )Nr   )r   r  )r  r  r  r  s    r   msg_callbackzwatch.<locals>.msg_callback8  s#    z7+-&--*'*+r   )DXJobLogStreamClientmetrics_top)numRecentMessagesrecurseJobsr  r  ^job-[0-9a-zA-Z]{24}$% does not look like a DNAnexus job IDr   )
terminatedfaileddoner  zOutput reused from %sr  excludeMetricsmetricsFormatr  )r  r  r  msg_output_formatprint_job_infozWatching job r  z and sub-jobsz . Press Ctrl+C to stop watching.r   )%r\   rZ   r[   r  metricsrJ   r   r  r  r  job_infor  r  r  r  rY   r`   r  dxpy.utils.job_log_clientr  r  r  r  r  rX  rF  r  r?  r.  r   r   r   r   connectr  rg   r   )r   level_color_mappingr  lvlr  incompatible_argsiargis_try_providedr  r  r  r  r#  r  r  r  r  r  r  s   `             @@@@@r   r  r    s   	0#%;	!,	957AF
 .ATTDQRGTSCaLTCTL4G[DSWXYSZ[C3Q<[3[7
 {{yDKK/DLLF4JB		;;9DKK7z*ghi'  )H  I!0$ 7		'  )s  t!0$ 7:&JM^&^_`I ll$.O)L*j	j			*		 k
		<<-OY[\_bbcf}}  AE  AG  G  JR  RF,'*AADFJXUF??#f,F	, L)-)A)A#'99 II'L "llU88+TZZ8EEF==,L ||ug!6:Z!Z;;93KKy)\)l;M.N.Z 23djZZ%

23{{!%X||v)-%&		(-_%(._%(<<5 lJ7-djj$,,]i  yE@D\`\i\ikJ ::JJo)dll":SUV(,		_r9 

$
  c U[b  (c'l#Q''(s*   Q-Q33Q9 BQ9 9	R*R%%R*c                  f    t         j                  j                  dddii      j                  d      S )Nr:  clientIpT)r?  r  system_whoamir-  r   r   r   r  r  r  s,    88!!8j$-?"@AEEjQQr   c                 8	   t        t        j                        }| j                  r7t        j                  j                  |dd i       t        t        d             y t        j                  j                         }t        j                  j                  |      s'd}t        |j                  |t        d                   t        t        d      dz          t        j                  j!                  |d      }|d	z   }t        j                  j                  t        j                  j#                  |            rt        j                  j                  t        j                  j#                  |            rot        t        d
      dj                  ||      z          t%        ddg      dk(  r+t        j&                  |       t        j&                  |       nut)        ||       y t        j                  j                  |      st        j                  j                  |      r*t        j&                  |       t        j&                  |       t+        j*                  t        j                  j!                  t        j                  j-                  d      d            D cg c]'  }t        j                  j                  |d d       s&|) }}dg|z   dgz   }t%        |d      }	|	dk(  r(	 t/        j0                  dd|g| j2                  z          nE|	t7        |      dz
  k(  rt9        d      }
|
d	z   }t        j                  j                  |
      r;t        j                  j                  |      rt        dj                  |
|             n|
j;                  d	      rdt        j                  j                  |
d d       rBt        j                  j                  |
      r#|
d d |
}}
t        dj                  |
|             n)t        dj                  |
             n||	   d d ||	   }}
t        j<                  |
|       t        j<                  ||       t)        ||       y c c}w # t.        j4                  $ r t        dt.        j4                  f       Y Cw xY w)NsshPublicKeyzSSH public key has been revokedzNThe DNAnexus configuration directory {d} does not exist. Use {c} to create it.dx login)r  czSelect an SSH key pair to use when connecting to DNAnexus jobs. The public key will be saved to your DNAnexus account (readable only by you). The private key will remain on this computer.r   ssh_idz.pubdxz@ is already configured to use the SSH key pair at:
    {}
    {}zUse this SSH key pairz(Select or create another SSH key pair...r   z~/.sshz*.pubz,Generate a new SSH key pair using ssh-keygenzSelect another SSH key pair...r   r  z
ssh-keygen-fz%Unable to generate a new SSH key pairr,  z$Enter the location of your SSH key: zUsing {} and {} as the key pairzUnable to find {k} and {k}.pub)r   )r   r?  r  revoker  user_updater   rg   ra  r  r_  r<  rf  rJ   r  r_   rl  r  rp   r   update_pub_keyr  
expanduser
subprocess
check_callssh_keygen_argsCalledProcessErrorr=  r   r  symlink)r   r  dnanexus_conf_dirr  key_destpub_key_destr   r  r   r  key_srcpub_key_srcs               r   
ssh_configr  u  s   t{{#G{{W~t&<=d456 KK99;ww~~/0bCSZZ"3tJ7GZHId l most 	u 77<< 18<&(77>>"''**845"''..IYIYZfIg:h$t*cjjkskw y y z,.XYZ^__		(#		,'w5WW^^H%)EIIhIIl#99RWW\\"''2D2DX2NPW%XYta]_]d]d]k]klmnqoqlr]sttABTIMmLnngq)Q;y%%|T8&DtG[G[&[\ W)) FG%.77>>'*rww~~k/J;BB7KXY%%f-"''.."2NSUSZSZSaSabiSj+23B<[G;BB7KXY=DDwDOP'.vs';WV_JJw)JJ{L1w-7 u 00 y@WaWtWtVwxys   'Q"Q")%Q' '/RRc                 (   t        |      5 }|j                         }t        j                  j	                  | d|i       d d d        t        dj                  |              t        t        dt        d      z   dz   dz                y # 1 sw Y   JxY w)Nr  zUpdated public key for user {}z7Your account has been configured for use with SSH. Use dx runz with the --allow-ssh, z@--ssh, or --debug-on options to launch jobs and connect to them.)	r$  r%  r?  r  r  r   r  rg   r_   )r  pub_key_filefhpub_keys       r   r  r    s    	l	 Ar'')W~w&?@A 

*
1
1'
:;	$H4PX>Y\uuQR S TA As   3BBc                  ~   	 t        t        j                  j                  t        j
                  j                         d            5 } t        t        j                  j                  t        t        j                              }d|vrt        d      | j                         |d   k7  rt        d      	 d d d        y # 1 sw Y   y xY w# t        $ rj}t        d      dj                  |      z   dz   t!        d      z   d	z   }t#        t%        |      d
      st'        t(        t        f       Y d }~y Y d }~y d }~ww xY w)Nz
ssh_id.pubr  z User's SSH public key is not setzPublic key mismatchzWarning:zH Unable to verify configuration of your account for SSH connectivity: {}z]. SSH connection will likely fail. To set up your account for SSH, quit this command and run dx ssh_configz$. Continue with the current command?Fr  r  )r$  r_  r<  rl  r?  ra  r  r   r  r   r  rK   r%  r  r\   r  r_   r   rg   rJ   ru  )r  	user_descr  r  s       r   r  r    s
   ="'',,t{{<<>MN 	5RT !7!7$++9NOIY.@AAwwyIn55344 6		5 	5 	5  =*o j q qrs ttmn?#$&LM T#Y6'7);<< 7	=s8   AC	 A,B=4C	 =CC	 C	 		D<AD77D<c                    t        j                  d| j                        st        | j                  dz          ddddddd}t	        t
        j                  | j                  |      }|d   dv rt        | j                   d|d    d	       |s
t                |j                  d
g       | j                  s1| j                  #| j                  D cg c]  }||	 c}| _
        nt               g| _
        | j                  r7| j                  j                  | j                  j                  d      d          t        fd| j                  D              s| j                  D ]  }|vsj                  |        t         j"                  j%                  dj'                  dj)                                     t
        j*                  j-                  | j                  d
i       t         j"                  j%                  dj'                  | j                               t         j"                  j/                          |d   dvr|d   dv rt        d| j                   d|d    d	       t1        j2                  d       t        j                  | j                  |      }t         j"                  j%                  d       t         j"                  j/                          |d   dvrt         j"                  j%                  d       t         j"                  j%                  d       t         j"                  j/                          dj'                  | j                        }d\  }}}	t5        d      D ]  }|j                  d      }|j                  di       j                  di       j                  d      }
|
t7        |
      j8                  }||}|}|j                  d      }|j                  d       xs d!}	|r|r nvt1        j2                  d       t        j                  | j                  |      }t         j"                  j%                  d       t         j"                  j/                           t         j"                  j%                  d       |r|s&d"}t        |j'                  | j                               t:        j<                  j)                  t
        j>                  jA                         d#      }tC        |d$      5 }|j%                  d%j'                  ||jE                         &             d d d        dd l#}d'}t         j"                  j%                  d(j'                  ||	             | j                  rL| j                  j                  d      }t         j"                  j%                  d)j'                  |d                t         j"                  j%                  d*       t         j"                  j/                          t5        d+      D ]  }	 | j                  rf|jG                         }|jI                  d   tK        |d         f       |jM                  d,      }|j%                  d-j'                  ||	.             n|jO                  ||	fd/0       d} n | j                  r"	 jS                          	 jS                          |r,t         j"                  j%                  tU        d2      dz          nUd3}t        |j'                  || j                  tW        d4j'                  | j                              5      tY               6       t[        d7j'                  ||	             d8d9t:        j<                  j)                  t
        j>                  jA                         d:      d;d<j'                  |      d;d=j'                  |      d>t]        |	      d?d@|g}| j                  r!|d;dAj'                  | j                  B      gz  }|| j^                  z  }ta        jb                  |      }	 t        j                  | j                  |      }| jd                  r~|d   dCk(  rvdDj'                  | j                        }tg        |d'E      rMt
        j*                  ji                  | j                         t[        dFj'                  | j                               to        |       y c c}w # 1 sw Y   xY w# tP        $ rV t1        j2                  d1       t         j"                  j%                  d       t         j"                  j/                          Y Dw xY w#  Y xY w#  Y xY w# tj        $ rI}dGtW        dH      z   dIz   }t[        tm        |j'                  | j                                     Y d }~d }~ww xY w)JNr  r  T)r   
sshHostKeyhttpsAppsshPortr  allowSSHrQ  r   )r  r  r  z is in terminal state z, and you cannot connect to itr  r   r   c              3   &   K   | ]  }|v  
 y wr  r   )rY  r  job_allow_sshs     r   r[  zssh.<locals>.<genexpr>  s     @22&@s   z+Updating allowed IP ranges for SSH to '{}'
r  rh  zWaiting for {} to start...)running
debug_holdr   r   r  z*Resolving job hostname and SSH host key...z{job_id}.dnanex.us)r  )NNNZ   r  r  dnsr\  r  r     zZCannot resolve hostname or hostkey for {}. Please check your permissions and run settings.ssh_known_hostsaz{known_host} {key}
)
known_hostrU  FzChecking connectivity to {}:{}z through proxy {}z...   zr+z0CONNECT {host}:{port} HTTP/1.0
host: {host}

)r  r     )r  rh  OKzFailed to connect to {h}. Please check your connectivity, verify your ssh client IP is added to job's allowedSSH list by describing the job and if needed, retry the command with additional --allow-ssh ADDRESS argument.z	dx ssh {})hr  r  r^  zConnecting to {}:{}r  -ir  -ozHostKeyAlias={}zUserKnownHostsFile={}-p-ldnanexusz+ProxyCommand=nc -X connect -x {proxy} %h %p)proxyr  z-Job {job_id} is still running. Terminate now?r  zTerminated {}.z?Unable to check the state of {job_id}. Please check it and use zdx terminate {job_id}z to stop it if necessary.)8rX  rF  r  rJ   r   r?  r.  r  r-  no_firewall_updater  r  r  r>  r  r   r   r   rb  r  rl  r  
job_updater  timesleepr  r   hostnamer_  r<  ra  r  r$  rstripsocketr  r  makefilecreate_connectionr  r,  r[   r_   r   r   r   r  r  callcheck_runningr   r  rN   rg   r  )r   r  ssh_desc_fieldsjob_descrZ  r  r  r  host_keyssh_portr\  
https_hostr  known_hosts_filer  r/  	connected
proxy_argsproxy_socket
proxy_filer  	exit_coder  r  r  s                           @r   r  r    s   88+T[[9FFG#4TVZdhvz{Ot{{?KH<<DKK= 6x7H6IIghiLLR0M "">>%)-IA1=aIDN ,o.DN>>NN!!$.."6"6s";A">?@@@nn -]*!((,- JJKRRSWS\S\]jSklmHH$++ZQ^D_`JJ188EFJJ
7
#<
<G @@r$++&<Xg=N<OOmno

1==_E



 7
#<
< JJTJJABJJ%,,DKK,@J/D(H2Y ||F#ll:r*..ub9==eD?!#//J%!'
<<-<<	*0bHJJqM}}T[[IHJJS!JJ#$ JJTXjDKK()ww||DKK$A$A$CEVW		$ ^
'..*(//J[.\]^ IJJ5<<T8LM~~^^))#.


,33JqMBCJJUJJ2Y 	~~%}}$$jmSA5G%HI)2248
  !Y"(&d&"BD (($)91(EI" ~~		  

tt+, kd4;;DASASTXT_T_A`<ab%<	) 


&
&tX
67tRWW\\$++*G*G*I8T'..z:-445EFc(mT:t=H ~~THV$..V13 	3H)I
4==_E(7"3y"@AHHPTP[P[H\CS%0&&t{{3&--dkk:;
 	Ou Jp^ ^0  	JJqMJJS!JJ			2 ' 4ORVWnRoo)*d3::T[[:12334s]   c)c)1c.B	c;2e e% 2B+e- .c8;Aeee"%e*-	f?6?f::f?c                 B   d}t        t        | j                  d      \  }}t        | j                  D cg c]  }t        |       c}      }	 t        j                  j                  ||d      d   }d }D cg c]	  }d|vs| }	}|D cg c]	  }d|v s| }
}t         ||	|            }t        dj                  t        |	      	             t        t        |j                                     }t!        |      D ]  \  }}fd
}dj                  | j"                  |      }d}d}t%        ||      5 }t'        j(                  ||      }dg|D cg c]  }| c}z   |D cg c]  }|dz   	 c}z   }|j+                  |       |D ]  }|j+                   ||              	 d d d        t        dj                  |              t        d       |
D ].  }t        dj                  |d                t        |d   j                               }||k7  r_t        d       t        dj                  dj-                  |                   t        dj                  dj-                  |                   t        |d   j/                               D ]c  \  }}t        |d         dkD  st        dj                  |              t        d!j                  |d"   dj-                  |d         #             e t        d       1 t        d$j                  t        |      |%             t        |
      d&kD  r&t        d'j                  t        |
      (      d)       y y c c}w #  t                Y xY wc c}w c c}w c c}w c c}w # 1 sw Y   xY w)*Ni  r  r  )r6  r  r  batchInputsc              3   V   K   t        dt        |       |      D ]  }| |||z      y wr   )r  r=  )lr  rZ  s      r   chunksz%generate_batch_inputs.<locals>.chunkse  s2     q#a&!$ 	AAa!e*	s   ')r  z=Found {num_success} valid batch IDs matching desired pattern.)num_successc                    | d   gt        | d   j                               D cg c]
  \  }}|d    c}}z   t        | d   j                               D cg c]  \  }}dz   |d   d   z    c}}z   S c c}}w c c}}w )NbatchPatternr  r;  r   idsr   )rd  r   )binameivalr6  s      r   flatten_batchz,generate_batch_inputs.<locals>.flatten_batcht  s    n%&&QRS[Q\QbQbQdJe)f;5$$v,)ff  ]c  de  fn  do  du  du  dw  ]x  jy  NY  NS  UYjqtwjwz~  @E  {F  GH  {I  kI  jy  y  y)f  jys   A7A=z{}.{:04d}.tsvrc  	)r   zbatch IDz IDzCreated batch file {}r   z1ERROR processing batch ID matching pattern "{id}"rF  )r  r  z"    Mismatched set of input names.z(        Required input names: {required}r  requiredz&        Matched input names: {matched})matchedrG  r   zGInput {iname} is associated with a file name that matches multiple IDs:)rI  z    {fname} => {ids}r;  )fnamerG  zDCREATED {num_batches} batch files each with at most {max} batch IDs.)num_batchesr+  r   zaERROR SUMMARY: Found {num_errors} batch IDs with incomplete or ambiguous results.  Details above.)
num_errorsrh  )r   ry   r<  rd  r   r   r?  r  system_generate_batch_inputsrJ   r   r   r  r=  rd  r  rD  output_prefixr$  r  writerwriterowrl  r   )r   MAX_BATCH_SIZEr  r4  keyeqval
input_dict
api_resultrC  rH  
successfulerrorsbatchesinput_namesrZ  batchrK  batch_fname
write_moder   csvfilebatchwriterrI  headersbiinput_names_i
input_namer  r6  s                              @r   generate_batch_inputsrh  V  s    N%lDIIQGVU DJJO)(3OPJHH99wZ`lv:wx  zG  Hz (<7!+;!<J<#4Aw!|a4F46*n56G
JQQ^abl^mQnojoo/01K W% <%	y &,,T-?-?C 
	+z* 	8g**W	BK!l%Ee%EEbmHnY^uHnnG  ) 8$$]2%678	8 	&--k:;#<( 2J DKKrR`OaKbcr(|0023=(78=DDdiiXcNdDef;BB499UbKcBde#'8(:(:(<#= 	lJ75>"Q&`ggnxgyz-4476?PTPYPYZabgZhPi4jk	l 	r
 QXXehipeq  xFX  G  H
6{Qt{{  HK  LR  HS{  T  VW  	X s P
z =4, &FHn	8 	8sS   M)&M. >	N N 	NN<N	N

#N+N
74N.M=

NN	c                 f   t        t        | j                  d      }	 |d   dk(  r1t        j                  j                  |d   d| j                  i       n0t        j                  j                  |d   d| j                  i       t        dj                  | j                               |d	   r,t        d
j                  dj                  |d	                      t        d       t        dj                  |d                t        dj                  |d                y #  t                Y y xY w)NT)is_version_requiredrR  r  r  makeDefaultr  zPublished {} successfullyr  z/It is now available to the authorized users: {}r  z!You can add or remove users with:z  dx add users {} user-xxxxr;  z  dx remove users {} user-yyyy)r   r}   r  r?  r  app_publishmake_defaultglobal_workflow_publishr   r  rl  rJ   r  s     r   r  r    s    -tTXYD=E!HH  d=$J[J[:\ ]HH,,T$Z}VZVgVgFh,i*11$//BC!"DKKDIIVZ[lVmLnop23,33DLAB/66tF|DE
s   DD" "D0c           	         d }d }d } ||       \  }}} || |||      \  }}}	| j                   rt        r|dk(  rT|r't        |      }
t        dj	                  |
|             nt        dj	                  ||| j
                  sdnd             n_|d	k(  rZt        j                  |	      }|j                  d
        ||||      }t        dj	                  |d   ||d   |d   dz               t        dd
      st        j                  d        |||	|      }| j                  sft                |dk(  rt        dj	                  |d   |             n-|d	k(  r(t        dj	                  |d   |d   |d   dz               t                y y )Nc           	         t         t        t        g}	  || |      }|S # t        $ r}t	        dj                  |             t        |      |v r0t	        dj                  |j                  |j                               n#t	        dj                  t        |                   t        dj                  |t        |            d       Y d }~S d }~ww xY w)NzFailed request: {}z     API error: {}. {}z     Unexpected error: {}zFailed request: {}. {}rh  code)r   r   r   r  r   r  r@  r;  r  rO   rJ   )target_projectrequest_inputrequest_func
api_errorsresr  s         r   send_archive_requestz%archive.<locals>.send_archive_request  s    "$46FG
		b~}=C 
  	b'..}=>Aw*$/66qvvquuEF299:J1:MNO-44]DTUVDWX_`aa
	bs   	 	CB CCc                    i }|rt        |      }d|i}n.|r|| j                  d}nt        dj                  |      d       | j                  }i }|dk(  r)d| j
                  i}t        j                  j                  }n-|dk(  r(d	| j                  i}t        j                  j                  }|j                  |       ||fS )
Nfilesr  z+No input file/folder is found in project {}rh  rq  archival	allCopies
unarchivalrate)r   r  rJ   r  request_mode
all_copiesr?  r  project_archiver~  project_unarchiver   )r   target_filestarget_folderrs  rt  r  optionsru  s           r   get_valid_archival_inputz)archive.<locals>.get_valid_archival_input  s    -L$l3M'4MMBII.Y`ab((:%"DOO4G8833L\)tyy)G8855LW%\=88r   c                    d }d }t               }| j                  D cg c]  }t        d|d       }}t               }t               }t               }|D ]  }	t        |	      dkD  r,t	        dj                  dj                  |	            d       nBt        |	      dk(  r|j                  |	d          nt        |	      d	k(  r|j                  d
       |	d   }
|
d   dk(  rJt        |
j                  d      rd
nd|
z         \  }}|r|j                  |
       |j                  |       |j                  |
        |D ]  }t        |      r|j                  d      rn|d
k(  r.t        j                  st	        dd       t        j                  }n|	 t        t        j                  |d            }r=t        |D cg c]  }dj                  |d   d   |d          c}d      }||   d   }nt	        dj                  |      d       |r#||k7  rt	        dj                  ||      d       |r|} |st	        dd       t        |      d	kD  rt	        dj                  	      d       |r|rt	        dd       |r|j!                         }nC|D ]=  }t#        |      r#|j                  d      r|j                  |       2t        
j                  d      rd
nd|z         \  }}	 t        t        j$                  d|||dd            }st	        dj                  ||      d       | j&                  svt        |D cg c]  }dj                  |d   d   |d          c}d      }|dk(  r$|j)                  |D cg c]  }|d   	 c}       |j                  ||   d          |j)                  |D cg c]  }|d   	 c}       @ |||fS c c}w #  t	        dj                  |      d       Y SxY wc c}w #  t	        dj                  ||      d       Y xY wc c}w c c}w c c}w ) Nr   T)include_empty_stringsr	   zQPath '{}' is invalid. Please check the inputs or check --help for example inputs.rh  rq  r   r   r   r  r  r;  z:Cannot find current project. Please check the environment.r  z Cannot find project with name {}z{} ({})r.  r;  r  F)r  zhAll paths must refer to files/folder in a single project, but two project ids: '{}' and '{}' are given. zeNo target project has been set. Please check the input or check your permission to the given project.zhOnly one folder is allowed for each request. Please check the inputs or check --help for example inputs.zHExpecting either a single folder or a list of files for each API requestzfile-r   )r  r;  r6  r  r.  r  z1Input '{}' is not found as a file in project '{}'*)rP  r<  r   r=  rJ   r  rl  r   ro   r	  rt   r?  PROJECT_CONTEXT_IDr   r  rp   poprs   r  r   r   )r   rs  r  r  r<  rt  possible_projectspossible_folderpossible_filesr  rZ  r  entity_nameprojproject_resultsrH  r  fprE  rV  file_resultsr   s                         r   get_archival_pathsz#archive.<locals>.get_archival_paths  s{   uTXT]T]^Dd$G^^E%  	(A1vaxlsstwt|t|}~t  A  HI  JQ1!%%ad+Q1!%%b)B%C2w#~&7s~~c?RX[_b8b&c#"&&s+#''/""3'!	(& & 	&Dt$)D..Y`ab..V&*4+=+=4RV+W&XO #!l{"|bh9#3#3F:4Fv4NPVW[P\#]"|  JO  PF*6248D?FFtLSTU$"7  D  K  K .6<=?#!%5	&< |  DE  F"  G  G  HI  J  QR  S~_fgh +//1M$ S ""%"--*@ $$R( ,=CNNSVDWb]`df=f+g(Jy'+D,B,BVZbky  BL  VZ  ch  -i  (j ( !T![![\^`n!ovwx88!%q}&~gm	(8(8
9KF9SU[\`Ua(b&~  KO  "P!S=(//0Ud0UV(,,\&-A$-GH$++L,QDT$Z,QR/S2 ]N::w _LV?FFtLSTUU #}Dy !T![![\^`n!ovwxx '0U -Rs5   O  O%>"P	
1$P	"P3
P8
P=
%PP0r{  z&Will tag {} file(s) for archival in {}z;Will tag file(s) for archival in folder {}:{} {}recursivelyznon-r   r}  T)dryRunzFWill tag {} file(s) for unarchival in {}, totalling {} GB, costing ${}rz  r  costr}  zConfirm all paths?r  r   z$Tagged {} file(s) for archival in {}countz>Tagged {} file(s) for unarchival, totalling {} GB, costing ${})r  r   r=  r   r  r  r  r8  r   r   r  r  r  )r   rx  r  r  r  r  rs  r  ru  rt  countsdryrun_request_input
dryrun_resrw  s                 r   r  r    s   9,`;F 3ET2J/L- 1I|]jlz0{-L, ||:%\*>EEf^\]SZZ[ikx  IM  IU  IU  {A  []  ^  _\)#'==#?  ''t'4-n>RT`aJZaablmtbu  xF  HR  SY  HZ  [e  fl  [m  nr  [r  s  t14@KKN ~}l
KC:::%8??G^\]\)RYYZ]^eZfhklrhstwx~t  AE  uE  F  G r   c           
         | j                   t        j                          y | j                   t        v rt	        d| j                   z   dz   t        | j                      d   j                         z          t	        d       t        | j                      d   D ]:  }t	        d|d   z   dd	t        |d         z
  z  z   t        |d
   dd      z          < y | j                   t        vrt        d| j                   z   d       y | j                   dk(  rr| j                  f| j                  t        vrt        d| j                  z   d       t        j                         }t        |ddg       t        | j                     |       y | j                   dk(  rD| j                  "t        | j                      j                          y t        | j                         y | j                  "t        | j                      j                          y | j                   dz   | j                  z   t        vr*t        d| j                   z   dz   | j                  z   d       y t        | j                   dz   | j                  z      j                          y )Ndx r  r   z
Commands:
r   rs  r   r      r   iz                    width_adjustmentr  zUnrecognized command: rh  r   z"Unsupported format for dx export: exporter_args-hr  z1Unrecognized command and subcommand combination: )command_or_categoryparser_helprn  parser_categoriesr   r  r=  rg   rm  rJ   
subcommand	exportersargparse	Namespacer  r  )r   r  new_argss      r   rn  rn  V  s   ' 		!	!%6	6ed...58I$JbJb8cdj8k8r8r8ttuo$T%=%=>vF 	wC$Q-#r#c!f+~"66c!fWZnt9uuv	w		!	!	3)D,D,DDaH		!	!X	-$//2M??)+9DOOKQO%%'/D62$//"8,		!	!U	*??"t//0;;=4??+		 4++,779

"
"S
(4??
::	MDtG_G__beehlhwhwwyz{4++c1DOOCDOOQr   c                 *    t         d   r
t               y )Nr   )r   r  r   s    r   
exit_shellr  r  s    ]o r   c                       e Zd ZddZy)runHelpNc                 P    |j                   t        |dd       t        |dd       y )Nr  r   rg  T)r  r  r   r  	namespacevaluesoption_strings        r   r   zrunHelp.__call__w  s&    'I|R0	64(r   r  r   r   r   r   r   r   r   r  r  v  s    )r   r  c                       e Zd ZddZy)runInputHelpNc                     t                y r  )r  r  s        r   r   zrunInputHelp.__call__}  s    r   r  r  r   r   r   r  r  |  s    r   r  c                       e Zd ZddZy)SetStagingEnvNc                     t        |dd       t        |dd       t        |dd       t        |dd       t        dd	dt        d
    xs |j                         y )Nr  zstagingauth.dnanexus.comr  443r  httpsr  Trw  r   r  )r  r  r   r  r  s        r   r   zSetStagingEnv.__call__  sW    	6#=>	65)	:w/	9d+'@u //A9>>	Dr   r  r  r   r   r   r  r    s    Dr   r  c                       e Zd ZddZy)PrintDXVersionNc                 ^    t        dt        j                         |j                  d       y )Nzdx vr   )r   r?  r  r  r  s        r   r   zPrintDXVersion.__call__  s    $..01Ar   r  r  r   r   r   r  r    s    r   r  c                       e Zd ZddZy)PrintCategoryHelpNc                 ^   |j                   dk(  rd}nd}t        d|j                   z   dz          t                t        t        dj                  |                   t                t        d       t        d	d
j	                  t        t                    z          |j                  d       y )Ndx find globalworkflowsr  appszusage: z --category CATEGORYzUList only the {et} that belong to a particular category by providing a category name.)etzCommon category names include:rs  rd  r   )progr   rg   r  rl  rd  rW   r  )r   r  r  r  r  exectypes         r   r   zPrintCategoryHelp.__call__  s    ;;33"HHi&++%(>>?djqqu}q~  	A./dV[[!7889Ar   r  r  r   r   r   r  r    s    r   r  c                   .     e Zd Zg Z	 	 d fd	Zd Z xZS )r  c           	      \    t        |t              rd}t        t        |   d|||||d| y )Nr   )option_stringsdestrN  r  nargsr   )r  boolsuperr  r   )r   r  r  rN  r  r  r   	__class__s          r   r   zDXNewUserOrgArgsAction.__init__  s;    gt$E$d4 	
)x5	
,2	
r   c                     t         j                  j                  |       t        | j                  t
              r#t        || j                  | j                          y t        || j                  |       y r  )r  r  r>  r  r  r  r  r  r  s        r   r   zDXNewUserOrgArgsAction.__call__  sK    2299-HdllD)Ityydll*:;Ityy&1r   )FNN)r   r   r   r  r   r   __classcell__)r  s   @r   r  r    s    EI
2r   r  c                   (    e Zd ZddZd ZddZd Zy)DXArgumentParserNc                     |rG|j                  d      r(d|v r$|j                  dd      }|j                  dd      }t        ||       y y )Nz"usage: dx [-h] [--version] commandz,dx: error: argument command: invalid choice:z
, notebookr   z, loupe-viewerr   )r	  r=  rj   )r   r  r   s      r   _print_messagezDXArgumentParser._print_message  sU    !!"FGLz  F  MF!//,r:!//*:2>'%	 r   c                    |j                   ||j                   vrt        dj                  dj                  |j                                     }dj                  ||      }t	        t
              dk(  rDddlm} |j                  ||j                         }||j                   v r|dt        d	|z         z   z  }t        j                  ||      }|y y )
Nz(choose from {})r  z"invalid choice: {choice}
{choices})r  r   r   r   )spelling_correctorz

Did you mean: r  )r   rg   r  rl  r=  	args_list
dxpy.utilsr  correctr_   r  ArgumentError)r   actionr  r   r  r  
suggestionerrs           r   _check_valuezDXArgumentParser._check_value  s    
 >>%%v~~*E-44TYYv~~5NOPG7>>eU\>]C9~"9/77v~~N
//$uz7I2JJJC((5CI +F%r   c                     t        |t              r|r||z   n|}d}|r | j                  |t        j                         t        j
                  |       y )Nr   )r  r   r  r   r   r  )r   statusr  s      r   r  zDXArgumentParser.exit  sB    fj)*1g&vGF4r   c                 |    | j                  ddj                  | j                         | j                  |             y )Nr	   z{help}
{prog}: error: {msg}
)rg  r  r  )r  r  r  r  )r   r  s     r   r  zDXArgumentParser.error  s:    		!5<<$BRBRBTBF))AH = J 	Kr   r  )r   N)r   r   r   r  r  r  r  r   r   r   r  r    s    &$Kr   r  Tc                 H   t        j                  dd| j                        }|t        }t	        |t
              r|f}| t        |<   |r[|j                  d   j                  }t        d   d   j                  ||f       |D ]  }t        |   d   j                  ||f       ! yy)a  Attaches `parser` to the global ``parser_map``. If `add_help` is truthy,
    then adds the helpstring of `parser` into the output of ``dx help...``, for
    each category in `categories`.

    :param subparsers_action: A special action object that is returned by
    ``ArgumentParser.add_subparsers(...)``, or None.
    :type subparsers_action: argparse._SubParsersAction, or None.
    z^dx r   Nr  r   r   )rX  r  r  r   r  r   rm  _choices_actionsrg  r  r>  )r  subparsers_action
categoriesadd_helpr;  _helprK  s          r   register_parserr    s     66&"fkk*D &*j) ^
Jt!2226;;% (//u>" 	FHh'/66e}E	F r   c                 V    t        |       }|dk  rt        j                  d| z        |S )Nr   z#%s is an invalid positive int value)r  r  ArgumentTypeError)r  ivalues     r   positive_integerr    s/    ZF{(()NQV)VWWMr   c                 V    t        |       }|dk  rt        j                  d| z        |S )Nr   z&%s is an invalid positive number value)floatr  r  )r  number_values     r   positive_numberr    s1    <Lq(()QTY)YZZr   z Command-Line Client, API vz
, client vra  zdx is a command-line client for interacting with the DNAnexus platform.  You can log in, navigate, upload, organize and share your data, launch analyses, and more.  For a quick tour of what the tool can do, seezd

  https://documentation.dnanexus.com/getting-started/tutorials/cli-quickstart#quickstart-for-cli

z:For a breakdown of dx commands by category, run "dx help".zdx exits with exit code 3 if invalid input is provided or an invalid operation is requested, and exit code 1 if an internal error is encountered.  The latter usually indicate bugs in dx; please report them atz1

  https://github.com/dnanexus/dx-toolkit/issuesz%%(prog)s [-h] [--version] command ...)r   formatter_classrq  usager  z&show program's version number and exit)r  r  rg  r  )rg  r  r  z4Log in (interactively or with an existing API token)zbLog in interactively and acquire credentials.  Use "--token" to log in with an existing API token.r  )rg  r   r  rq  z--tokenzAuthentication token to use)rg  z--hostz=Log into the given auth server host (port must also be given)z--portz=Log into the given auth server port (host must also be given))r@  rg  z
--protocolzgUsed in conjunction with host and port arguments, gives the protocol to use when contacting auth serverr  )rg  r  z--noprojectsr  zDo not print available projectsstore_false)r  rg  r  z--savez>Save token and other environment variables for future sessions
store_true)rg  r  z	--timeout30dzLTimeout for this login token (in seconds, or use suffix s, m, h, d, w, M, y))r  rg  z	--staging)r  rg  r  )r  funcr   )r  r  zLog out and remove credentialsr  z?Log out of the given auth server host (port must also be given)z?Log out of the given auth server port (host must also be given))r  r  z!Exit out of the interactive shellzdx exit)rg  r   r  r  z&Print the username of the current userzCPrint the username of the current user, in the form "user-USERNAME"z	dx whoamiz--idz!Print user ID instead of usernamer  )rg  r  r  r  z&Print all environment variables in usezPrints all environment variables in use as they have been resolved from environment variables and configuration files.  For more details, seezt

https://documentation.dnanexus.com/user/helpstrings-of-sdk-command-line-utilities#overriding-environment-variableszdx env)rg  r   r  r  rq  z--bashzBPrints a list of bash commands to export the environment variablesi)r  z
--dx-flagsz;Prints the dx options to override the environment variablesr  z*Sets environment variables for the sessionz@Sets environment variables for communication with the API serverz	dx setenvzSave settings for future sessions.  Only one set of settings can be saved at a time.  Always set to true if login is run in a non-interactive sessionz	--currentznDo not prompt for new values and just save current settings for future sessions.  Overrides --save to be true.r   r	  z*Clears all environment variables set by dxzClears all environment variables set by dx.  More specifically, it removes local state stored in ~/.dnanexus_config/environment.  Does not affect the environment variables currently set in your shell.zdx clearenvz--resetzReset dx environment variables to empty values. Use this to avoid interference between multiple dx sessions when using shell environment variables.)r  r   r5  z2Invite another user to a project or make it publiczInvite a DNAnexus entity to a project. If the invitee is not recognized as a DNAnexus ID, it will be treated as a username, i.e. "dx invite alice : VIEW" is equivalent to inviting the user with user ID "user-alice" to view your current default project.z	dx inviter/  zEntity to inviter6  z Project to invite the invitee tor   ?)rg  r  r  r   z,Permissions level the new member should have)r  r.  r  r/  r  )rg  r   r  r  z
--no-emailr2  z&Disable email notifications to invitee)r  r  rg  r:  z6Revoke others' permissions on a project you administera  Revoke others' permissions on a project you administer. If the entity is not recognized as a DNAnexus ID, it will be treated as a username, i.e. "dx uninvite alice :" is equivalent to revoking the permissions of the user with user ID "user-alice" to your current default project.zdx uninviter8  zEntity to uninvitez"Project to revoke permissions fromr$  z'List folders and/or objects in a folderzdx ls)rg  r   rq  r  z-az--allzshow hidden filesr&  z--longrb  zAlias for "verbose"z--objzshow only objectsz	--folderszshow only foldersz--fullzshow full paths of foldersr<  zFolder (possibly in another project) to list the contents of, default is the current directory in the current project.  Syntax: projectID:/folder/pathr  )rg  r  r  r   r  z"List folders and objects in a treezdx treezuse a long listing formatr  r  r  zPrint current working directoryzdx pwdr>  z&List and select a project to switch tozInteractively list and select a project to switch to.  By default, only lists projects for which you have at least CONTRIBUTE permissions.  Use --public to see the list of public projects.z	dx selectzUName or ID of a project to switch to; if not provided a list will be provided for your7  z--namez1Name of the project (wildcard patterns supported)z--levelz%Minimum level of permissions expectedr  )r   rg  r  z--publiczEInclude ONLY public projects (will automatically set --level to VIEW))r  r  r  z$Change the current working directoryzdx cdr  z|Folder (possibly in another project) to which to change the current working directory, default is "/" in the current project)r  r  rg  r   z6Copy objects and/or folders between different projectszCopy objects and/or folders between different projects.  Folders will automatically be copied recursively.  To specify which project to use as a source or destination, prepend the path or ID of the object/folder with the project ID or name and a colon.z

EXAMPLES

  aE  The first example copies a file in a project called "FirstProj" to the current directory of the current project.  The second example copies the object named "reads.fq.gz" in the current directory to the folder /folder/path in the project with ID "project-B0VK6F6gpqG6z7JGkbqQ000Q", and finally renaming it to "newname.fq.gz".rs  r  z

  $ dx cp FirstProj:file-B0XBQFygpqGK8ZPjbk0Q000q .
  $ dx cp reads.fq.gz project-B0VK6F6gpqG6z7JGkbqQ000Q:/folder/path/newname.fq.gz
zdx cp)rg  r  r   r  rq  r  z#Objects and/or folder names to copyr  +)rg  metavarr  r  zFolder into which to copy the sources or new pathname (if only one source is provided).  Must be in a different project/container than all source paths.iz--target-file-relocationzQAllow symlink target file relocation in external storage while cloning a symlink.)rg  r  r  r&  z6Move or rename objects and/or folders inside a projectzMove or rename data objects and/or folders inside a single project.  To copy data between different projects, use 'dx cp' instead.zdx mvz#Objects and/or folder names to movezFolder into which to move the sources or new pathname (if only one source is provided).  Must be in the same project/container as all source paths.zPAllow symlink target file relocation in external storage while moving a symlink.r  zCreate a new folderzdx mkdirr%  z	--parentsz9no error if existing, create parent directories as neededrt  zPaths to folders to creater  zRemove a folderzdx rmdirzPaths to folders to remover%  zRemove data objects and foldersz Remove data objects and folders.zdx rmzPaths to removez-rz--recursivezRecurse into a directoryr  z--forcezForce removal of filesr.  zDescribe a remote objectaw  Describe a DNAnexus entity.  Use this command to describe data objects by name or ID, jobs, apps, users, organizations, etc.  If using the "--json" flag, it will thrown an error if more than one match is found (but if you would like a JSON array of the describe hashes of all matches, then provide the "--multi" flag).  Otherwise, it will always display all results it finds.z

NOTES:

- zThe project found in the path is used as a HINT when you are using an object ID; you may still get a result if you have access to a copy of the object in some other project, but if it exists in the specified project, its description will be returned.z

- znWhen describing apps or applets, options marked as advanced inputs will be hidden unless --verbose is providedzdx describe)rg  r   r  rq  r  z	--detailszInclude details of data objectsz	--verbosezInclude additional metadataz+Only print the matching names, one per linez--multiziIf the flag --json is also provided, then returns a JSON array of describe hashes of all matching resultsiz--tryTr  zwWhen describing a job that was restarted, describe job try T. T=0 refers to the first try. Default is the last job try.)r  r  r@  rg  zIObject ID or path to an object (possibly in another project) to describe.)r   r   r  zUpload file(s) or directoryae  Upload local file(s) or directory.  If "-" is provided, stdin will be used instead.  By default, the filename will be used as its new name.  If --path/--destination is provided with a path ending in a slash, the filename will be used, and the folder path will be used as a destination.  If it does not end in a slash, then it will be used as the final name.z	dx uploadrV  z}Local file or directory to upload ("-" indicates stdin input); provide multiple times to upload multiple files or directories)r  rg  r$  z--outputz--pathz--destinationz\DNAnexus path to upload file(s) to (default uses current project and folder if not provided))rg  r  zUpload directories recursivelyz--waitz(Wait until the file has finished closingz--no-progresszDo not show a progress barr  )rg  r  r  r  z--buffer-sizez$Set the write buffer size (in bytes)r  z--singlethreadzEnable singlethreaded uploadingr  )rg  r  r  )r  r  r   r   zDownload file(s)zgDownload the contents of a file object or multiple objects.  Use "-o -" to direct the output to stdout.zdx downloadz-Data object ID or name, or folder to download)rg  r  r  r   r#  zLocal filename or directory to be used ("-" indicates stdout output); if not supplied or a directory is given, the object's name on the platform will be used, along with any applicable extensionsz--overwritezResume an interupted download if the local and remote file signatures match.  If the signatures do not match the local file will be overwritten.zDownload folders recursivelyz9If multiple objects match the input, download all of themz--lightweightz2Skip some validation steps to make fewer API callsz--symlink-max-trieszHSet maximum number of tries for downloading symlinked files using aria2c   )rg  r@  r  z	--unicodez=Display the characters as text/unicode when writing to stdoutr  r^  z'Create a file download link for sharingzXCreates a pre-authenticated link that can be used to download a file without logging in.zdx make_download_urlzhProject-qualified data object ID or name, e.g. project-xxxx:file-yyyy, or project-xxxx:/path/to/file.txtz
--durationzhTime for which the URL will remain valid (in seconds, or use suffix s, m, h, d, w, M, y). Default: 1 dayz
--filenamez[Name that the server will instruct the client to save the file as (default is the filename)r"  zPrint file(s) to stdoutzdx cat)rg  r  rq  z%File ID or name(s) to print to stdoutr!  zPrint part of a filezGPrint the first part of a file.  By default, prints the first 10 lines.zdx headz-nz--linesNz$Print the first N lines (default 10)r  )r@  r  rg  r  zFile ID or name to accessr  z&Create a new applet/app, or a workflowzBuild an applet, app, or workflow object from a local source directory or an app from an existing applet in the platform. You can use zdx-app-wizardzL to generate a skeleton directory of an app/applet with the necessary files.ry  z,Options for creating apps or globalworkflowszZ(Only valid when --app/--create-app/--globalworkflow/--create-globalworkflow is specified)z)Options for creating applets or workflowsz^(Only valid when --app/--create-app/--globalworkflow/--create-globalworkflow is NOT specified)z%Options for creating Nextflow appletsz)(Only valid when --nextflow is specified)r  zIf specified, will bypass computing checksum of resources directory and upload it unconditionally; by default, will compute checksum and upload only if it differs from a previously uploaded resources bundle.r  aO  If specified, will not attempt to dereference symbolic links pointing outside of the resource directory.  By default, any symlinks within the resource directory are kept as links while links to files outside the resource directory are dereferenced (note that links to directories outside of the resource directory will cause an error).r  zxSource directory that contains dxapp.json, dxworkflow.json or *.nf (for --nextflow option). (default: current directory)z--appz--create-appzCreate an app.store_constr  r  )rg  r  r  constz--create-appletr  z
--workflowz--create-workflowzCreate a workflow.r   z--globalworkflowz--create-globalworkflowzCreate a global workflow.r  z-dzSpecifies the destination project, destination folder, and/or name for the applet, in the form [PROJECT_NAME_OR_ID:][/[FOLDER/][NAME]]. Overrides the project, folder, and name fields of the dxapp.json or dxworkflow.json, if they were supplied.)r  z	--dry-runzDo not create an app(let): only perform local checks and compilation steps, and show the spec of the app(let) that would have been created.r  z--no-dry-run)r  z	--publishzAPublish the resulting app/globalworkflow and make it the default.r  z--no-publishz--fromzID or path of the source applet/workflow to create an app/globalworkflow from. Source directory src_dir cannot be given when using this optionr  )r  r  zBuild the app remotely by uploading the source directory to the DNAnexus Platform and building it there. This option is useful if you would otherwise need to cross-compile the app(let) to target the Execution Environment.r  z
--no-watchzDon't watch the real-time logs of the remote builder (this option is only applicable if --remote or --repository is specified).r  z--no-remotezuRemove existing applet(s) of the same name in the destination folder. This option is not yet supported for workflows.r  zvArchive existing applet(s) of the same name in the destination folder. This option is not yet supported for workflows.z-vzqOverride the version number supplied in the manifest. This option needs to be specified when using --from option.r  VERSION)rg  r  r  r  z-br  zQEntity (of the form user-NAME or org-ORGNAME) to bill for the app/globalworkflow.r  USER_OR_ORG)check_syntaxz--check-syntaxr  z--no-check-syntaxzXWarn but do not fail when syntax problems are found (default is to fail on such errors).)version_autonumberingz--version-autonumberingr  z--no-version-autonumberingzOnly attempt to create the version number supplied in the manifest (that is, do not try to create an autonumbered version such as 1.2.3+git.ab1b1c1d if 1.2.3 already exists and is published).)r   z--updater   z--no-updatezANever update an existing unpublished app/globalworkflow in place.z--dx-toolkit-legacy-git-autodepdx_toolkit_autodepgitz--dx-toolkit-stable-autodepstablez--dx-toolkit-autodepz--no-dx-toolkit-autodep)r  z--parallel-buildr  z--no-parallel-buildzBuild with makez instead of zmake -jN)use_temp_build_projectz--no-temp-build-projectzpWhen building an app in a single region, build its applet in the current project instead of a temporary project.r  z-yz--yesr  z@Do not ask for confirmation for potentially dangerous operations)r   z--jsonr   z	--no-jsonr  z_Arguments (in JSON format) to pass to the /applet/new API method, overriding all other settingsr  zNRun the app or applet after building it (options following this are passed to r	  z#; run at high priority by default).r  r>  a  Enable the app/globalworkflow in this region. This flag can be specified multiple times to enable the app/globalworkflow in multiple regions. If --region is not specified, then the enabled region(s) will be determined by 'regionalOptions' in dxapp.json, or the project context.)r  rg  z--keep-openzhDo not close workflow after building it. Cannot be used when building apps, applets or global workflows.z
--nextflowzBuild Nextflow applet.z	--profilez*Default profile for the Nextflow pipeline.profilez--repositoryzNSpecifies a Git repository of a Nextflow pipeline. Incompatible with --remote.r  z--repository-tagzESpecifies tag for Git repository. Can be used only with --repository.r'  z--git-credentialszGit credentials used to access Nextflow pipelines from private Git repositories. Can be used only with --repository. More information about the file syntax can be found at https://www.nextflow.io/blog/2021/configure-git-repositories-with-nextflow.html.r  z--cache-dockerzStores a container image tarball in the currently selected project in /.cached_dockerImages. Currently only docker engine is supported. Incompatible with --remote, --force, --archive, --dry-run, --json.r  z--docker-secretsz>A dx file id with credentials for a private docker repository.docker_secretsz--nextflow-pipeline-paramszNCustom pipeline parameters to be referenced when collecting the docker images.nextflow_pipeline_paramsr   )build_assetr  zBuild an asset bundlezBuild an asset from a local source directory. The directory must have a file called "dxasset.json" containing valid JSON. For more details, see 

https://documentation.dnanexus.com/developer/apps/dependency-management/asset-build-processzdx build_asset)rg  r  r   r  z3Asset source directory (default: current directory)z{Specifies the destination project and destination folder for the asset, in the form [PROJECT_NAME_OR_ID:][/[FOLDER/][NAME]]z0Show ID of resulting asset bundle in JSON formatz8Don't watch the real-time logs of the asset-builder job.z
--priorityr,  r-  )r   rg  r   zAdd one or more items to a listzUse this command with one of the availabile subcommands to perform various actions such as adding other users or orgs to the list of developers or authorized users of an appzdx add)parser_class	list_typer   r  zAdd authorized users for an appzAdd users or orgs to the list of authorized users of an app.  Published versions of the app will only be accessible to users represented by this list and to developers of the app.  Unpublished versions are restricted to the developers.zdx add users)r<  zName or ID of an appauthorizedUserz One or more users or orgs to add)r  rg  r  )r  r  r  zAdd developers for an appzAdd users or orgs to the list of developers for an app.  Developers are able to build and publish new versions of the app, and add or remove others from the list of developers and authorized users.zdx add developersrO  rX  zAdd a stage to a workflowzZAdd a stage to a workflow.  Default inputs for the stage can also be set at the same time.zdx add stagezName or ID of a workflowr  z=Name or ID of an executable to add as a stage in the workflowz--aliasz--tagrq  z[Tag or version of the app to add if the executable is an app (default: "default" if an app))r  rg  z
Stage namestage_idzStage IDz--output-folderzIPath to the output folder for the stage (interpreted as an absolute path)z--relative-output-folderz^A relative folder path for the stage (interpreted as relative to the workflow's output folder)memberz!Grant a user membership to an orgzdx add memberorg_idzID of the orgusername_or_user_idzUsername or ID of userADMINMEMBERz?Org membership level that will be granted to the specified user)rN  r   rg  z--allow-billable-activitiesz=Grant the specified user "allowBillableActivities" in the org)r  r  rg  z--no-app-access
app_accessz5Disable "appAccess" for the specified user in the org)r  r  r  rg  z--project-access)r/  r  r.  r  NONEzThe default implicit maximum permission the specified user will receive to projects explicitly shared with the org; default CONTRIBUTE)r   r  rg  z?Disable org invitation email notification to the specified userr   r   zPrint the members of a listzUse this command with one of the availabile subcommands to perform various actions such as printing the list of developers or authorized users of an app.zdx listz List authorized users for an appzList the authorized users of an app.  Published versions of the app will only be accessible to users represented by this list and to developers of the app.  Unpublished versions are restricted to the developerszdx list userszList developers for an appzList the developers for an app.  Developers are able to build and publish new versions of the app, and add or remove others from the list of developers and authorized users.zdx list developersr  zList the stages in a workflowzList the stages in a workflow.zdx list stagesrj  z?List entities associated with a specific database. For example,z

	zR"dx list database files" lists database files associated with a specific database.z:Please execute "dx list database -h" for more information.z2List entities associated with a specific database.zdx list database)r  entitiesrz  z.List files associated with a specific databasezdx list database filesz'Data object ID or path of the database.z--folderzName of folder (directory) in which to start searching for database files. This will typically match the name of the table whose files are of interest. The default value is "/" which will start the search at the root folder of the database.z	--recursezgLook for files recursively down the directory structure. Otherwise, by default, only look on one level.)r  rg  r  z--csvz?Write output as comma delimited fields, suitable as CSV format.x   zbNumber of seconds to wait before aborting the request. If omitted, default timeout is 120 seconds.)r  rg  r@  r   z"Remove one or more items to a listzUse this command with one of the available subcommands to perform various actions such as removing other users from the list of developers or authorized users of an app.z	dx removez"Remove authorized users for an appzRemove users or orgs from the list of authorized users of an app.  Published versions of the app will only be accessible to users represented by this list and to developers of the app.  Unpublished versions are restricted to the developerszdx remove usersz#One or more users or orgs to removezRemove developers for an appzRemove users or orgs from the list of developers for an app.  Developers are able to build and publish new versions of the app, and add or remove others from the list of developers and authorized users.zdx remove developerszOne or more users to removezRemove a stage from a workflowzRemove a stage from a workflow.  The stage should be indicated either by an integer (0-indexed, i.e. "0" for the first stage), or a stage ID.zdx remove stagez-Stage (index or ID) of the workflow to removez#Revoke the org membership of a userzdx remove memberz#--keep-explicit-project-permissionsrevoke_project_permissionszDisable revocation of explicit project permissions of the specified user to projects billed to the org; implicit project permissions (i.e. those granted to the specified user via his membership in this org) will always be revokedz--keep-explicit-app-permissionsrevoke_app_permissionszDisable revocation of explicit app developer and user permissions of the specified user to apps billed to the org; implicit app permissions (i.e. those granted to the specified user via his membership in this org) will always be revokedzDo not ask for confirmation)r  r  rg  z Update certain types of metadataz
Use this command with one of the available targets listed below to update
their metadata that are not covered by the other
subcommands.z	dx updatetargetzUpdate information about an orgzdx update orgzNew name of the orgz--member-list-visibilityzNew org membership level that is required to be able to view the membership level and/or permissions of any other member in the specified org (corresponds to the memberListVisibility org policy))r  r  r,  )rg  r   z--project-transfer-abilityzNew org membership level that is required to be able to change the billing account of a project that is billed to the specified org, to some other entity (corresponds to the restrictProjectTransfer org policy)z
--saml-idpzNew SAML identity providerz&--detailed-job-metrics-collect-defaulttruefalsezmIf set to true, jobs launched in the projects billed to this org will collect detailed job metrics by defaultrM  z--enable-job-reusez9Enable job reuse for projects where the org is the billToz--disable-job-reusez:Disable job reuse for projects where the org is the billToz--job-logs-forwarding-jsonJLFzJLF is a JSON string with url and token enabling forwarding of job logs to Splunk, e.g. '{"url":"https://http-inputs-acme.splunkcloud.com/event/collector","token":"splunk-hec-token"}')r  rg  z"Update the metadata for a workflowz,Update the metadata for an existing workflowzdx update workflowz--titlezWorkflow titlez
--no-titlezUnset the workflow titlez	--summaryzWorkflow summaryz--descriptionzWorkflow descriptionz&Default output folder for the workflowz--no-output-folderz0Unset the default output folder for the workflowz-Update the metadata for a stage in a workflowzdx update stagez-Stage (index or ID) of the workflow to updatez--executablez3Name or ID of an executable to replace in the stagezmTag or version of the app to use if replacing the stage executable with an app (default: "default" if an app)zsWhether to replace the executable even if it the new one cannot be verified as compatible with the previous versionz	--no-namezUnset the stage namez)Update the membership of a user in an orgzdx update memberz2The new org membership level of the specified userzThe new "allowBillableActivities" membership permission of the specified user in the org; default false if demoting the specified user from ADMIN to MEMBERz--app-accesszThe new "appAccess" membership permission of the specified user in the org; default true if demoting the specified user from ADMIN to MEMBERzThe new default implicit maximum permission the specified user will receive to projects explicitly shared with the org; default CONTRIBUTE if demoting the specified user from ADMIN to MEMBERz6Updates a specified project with the specified optionszdx update projectrj  zProject ID or project namezNew project namezProject summaryzProject descriptionz--protectedz'Whether the project should be PROTECTEDz--restrictedz(Whether the project should be RESTRICTEDz--download-restrictedz1Whether the project should be DOWNLOAD RESTRICTEDz--preview-viewer-restrictedzDWhether file preview and viewer should be restricted for the projectz--containsPHIz$Flag to tell if project contains PHIz--external-upload-restrictedzJWhether uploads of file and table data to the project should be restrictedz--database-ui-view-onlyzHWhether the viewers on the project can access the database data directlyz0Update the user or org ID of the billing account)rg  r@  z--https-app-isolated-browsingzWhether all https access to jobs in this project should be wrapped in Isolated Browsing. If true, httpsApp-enabled executables must have httpsApp.shared_access set to 'NONE' to run in this project.z%--https-app-isolated-browsing-optionszA JSON string with options for Isolated Browsing. See https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-update for a list of supported keys.z--allowed-executableszlExecutable ID(s) this project is allowed to run.  This operation overrides any existing list of executables.)rg  r@  r  z--unset-allowed-executableszJRemoves any restriction to run executables as set by --allowed-executablesz--database-results-restrictedz]Viewers on the project can access only more than specified size of visual data from databasesz#--unset-database-results-restrictedz]Removes any restriction to return data from databases as set by --database-results-restrictedr   r8  zInstall an appzkInstall an app by name.  To see a list of apps you can install, hit <TAB> twice after "dx install" or run "zdx find appsz"" to see a list of available apps.z
dx installzID or name of app to installr9  zUninstall an appzUninstall an app by name.zdx uninstallzID or name of app to uninstallr  zRun an applet, app, or workflowzsRun an applet, app, or workflow.  To see a list of executables you can run, hit <TAB> twice after "dx run" or run "z" or "r  z7" to see a list of available apps and global workflows.zIf any inputs are required but not specified, an interactive mode for selecting inputs will be launched.  Inputs can be set in multiple ways.  Run "zdx run --input-helpz" for more details.zRun "zdx run --instance-type-helpzM" to see a list of specifications for computers available to run executables.)rg  r  r   r  r  rq  zXName or ID of an applet, app, or workflow to run; must be provided if --clone is not setr  r  z--depends-onzID of job, analysis, or data object that must be in the "done" or "closed" state, as appropriate, before this executable can be run; repeat as necessary (e.g. "--depends-on id1 ... --depends-on idN"). Cannot be supplied when running workflows)rg  r  r@  r  --helpzshow this help message and exit)rg  r  r  z--clonea`  Job or analysis ID or name from which to use as default options (will use the exact same executable ID, destination project and folder, job input, instance type requests, and a similar name unless explicitly overridden by command-line arguments. When using an analysis with --clone a workflow executable cannot be overriden and should not be provided.)zGAlias (tag) or version of the app to run (default: "default" if an app)PATHztThe full project:folder path in which to output the results. By default, the current working directory will be used.)r  r  rg  z--batch-foldersr  zOutput results to separate folders, one per batch, using batch ID as the name of the output folder. The batch output folder location will be relative to the path set in --destinationz	--projectPROJECTzProject name or ID in which to run the executable. This can also be specified together with the output folder in --destination.z--stage-output-folder)STAGE_IDFOLDERzVA stage identifier (ID, name, or index), and a folder path to use as its output folder)r  rg  r  r  r  z--stage-relative-output-folderz}A stage identifier (ID, name, or index), and a relative folder path to the workflow output folder to use as the output folderz4Name for the job (default is the app or applet name)z--delay-workspace-destructionzqWhether to keep the job's temporary workspace around for debugging purposes for 3 days after it succeeds or fails)r+  r,  r-  zzRequest a scheduling priority for all resulting jobs. Defaults to high when --watch, --ssh, or --allow-ssh flags are used.z--head-job-on-demandzRequests that the head job of an app or applet be run in an on-demand instance. Note that --head-job-on-demand option will override the --priority setting for the head jobz+Wait until the job is done before returningz--watchz>Watch the job after launching it. Defaults --priority to high.z--allow-sshADDRESSa  Configure the job to allow SSH access. Defaults --priority to high. If an argument is supplied, it is interpreted as an IP range, e.g. "--allow-ssh 1.2.3.4". If no argument is supplied then the client IP visible to the DNAnexus API server will be used by default)r  r  r  rg  z--sshzeConfigure the job to allow SSH access and connect to it after launching. Defaults --priority to high.r  z<address>:<port>zNSSH connect via proxy, argument supplied is used as the proxy address and portz
--debug-on)r  r  r  r  r  zKConfigure the job to hold for debugging when any of the listed errors occur)r  r   rg  z--ignore-reusezDisable job reuse for executionz--ignore-reuse-stager#  r  a5  A stage (using its ID, name, or index) for which job reuse should be disabled, if a stage points to another (nested) workflow the ignore reuse option will be applied to the whole subworkflow. This option overwrites any ignoreReuse fields set on app(let)s or the workflow during build time; repeat as necessary)r  r  rg  r  z--rerun-stager#  zsA stage (using its ID, name, or index) to rerun, or "*" to indicate all stages should be rerun; repeat as necessaryz--batch-tsvr  FILEzA file in tab separated value (tsv) format, with a subset of the executable input arguments. A job will be launched for each table row.)r  r  rg  z''{"entrypoint": <number of instances>}'z--instance-countINSTANCE_COUNT_OR_MAPPINGzYSpecify spark cluster instance count(s). It can be an int or a mapping of the format {ic})ic)r  rg  r  z--input-helpz1Print help and examples for how to specify inputs)rg  r  r  z--detachzWhen invoked from a job, detaches the new job from the creator job so the new job will appear as a typical root execution. Setting DX_RUN_DETACH environment variable to 1 causes this option to be set by default.z--cost-limitzMaximum cost of the job before termination. In case of workflows it is cost of the entire analysis job. For batch run, this limit is applied per job.r$  )rg  r  r@  z--rankzSet the rank of the root execution, integer between -1024 and 1023. Requires executionRankEnabled license feature for the billTo. Default is 0.)r@  r  rg  z--max-tree-spot-wait-timezThe amount of time allocated to each path in the root execution's tree to wait for Spot (in seconds, or use suffix s, m, h, d, w, M, y)z--max-job-spot-wait-timezThe amount of time allocated to each job in the root execution's tree to wait for Spot (in seconds, or use suffix s, m, h, d, w, M, y)z--detailed-job-metricsz>Collect CPU, memory, network and disk metrics every 60 seconds)r  r  rg  z--preserve-job-outputsa  Copy cloneable outputs of every non-reused job entering "done" state in this root execution R into the "intermediateJobOutputs" subfolder under R's output folder.  As R's root job or root analysis' stages complete, R's regular outputs will be moved to R's regular output folder.z--preserve-job-outputs-folderJOB_OUTPUTS_FOLDERaE  Similar to --preserve-job-outputs, copy cloneable outputs of every non-reused job entering "done" state in this root execution to the specified folder in the project.  JOB_OUTPUTS_FOLDER starting with '/' refers to an absolute path within the project, otherwise, it refers to a subfolder under root execution's output folder.)r  rb  rg  r  r!  r"  r*  z#Watch logs of a job and its subjobszdx watchz6Monitors logging output from a running or finished job)rg  r  r   rq  r  zID of the job to watchz--num-recent-messagesz Number of recent messages to geti   z--treezInclude the entire job treeziAllows to watch older tries of a restarted job. T=0 refers to the first try. Default is the last job try.z--levels)r  r  r  r  r  r  r  r  r  r  r  )r  r   z--get-stdoutz!Extract stdout only from this jobz--get-stderrz!Extract stderr only from this jobz--get-streamsz,Extract only stdout and stderr from this jobz--no-timestampszOmit timestamps from messagesr  z	--job-idszPrint job ID in each messagez--no-job-infoz Omit job info and status updatesr  z-qz--quietz Do not print extra info messagesz--formatz<Message format. Available fields: job, try, level, msg, datez	--no-waitz--no-followr  zMExit after the first new message is received, instead of waiting for all logsz	--metricszSelect display mode for detailed job metrics if they were collected and are available based on retention policy; see --metrics-help for details)interspersedr  r  r  r*  )rg  r   r  c                       e Zd ZddZy)MetricsHelpActionNc                 <    t        d       |j                  d       y )Nu
  Help: Displaying detailed job metrics
Detailed job metrics describe job's consumption of CPU, memory, disk, network, etc at 60 second intervals.
If collection of job metrics was enabled for a job (e.g with dx run --detailed-job-metrics), the metrics can be displayed by "dx watch" for 15 days from the time the job started running.

Note that all reported data-related values are in base 2 units - i.e. 1 MB = 1024 * 1024 bytes.

The "interspersed" default mode shows METRICS job log messages interspersed with other jog log messages.

The "none" mode omits all METRICS messages from "dx watch" output.

The "top" mode interactively shows the latest METRICS message at the top of the screen and updates it for running jobs instead of showing every METRICS message interspersed with the currently-displayed job log messages. For completed jobs, this mode does not show any metrics. Built-in help describing key bindings is available by pressing "?".

The "csv" mode outputs the following columns with headers in csv format to stdout:
- timestamp: An integer number representing the number of milliseconds since the Unix epoch.
- cpuCount: A number of CPUs available on the instance that ran the job.
- cpuUsageUser: The percentage of cpu time spent in user mode on the instance during the metric collection period.
- cpuUsageSystem: The percentage of cpu time spent in system mode on the instance during the metric collection period.
- cpuUsageIowait: The percentage of cpu time spent in waiting for I/O operations to complete on the instance during the metric collection period.
- cpuUsageIdle: The percentage of cpu time spent in waiting for I/O operations to complete on the instance during the metric collection period.
- memoryUsedBytes: Bytes of memory used (calculated as total - free - buffers - cache - slab_reclaimable + shared_memory).
- memoryTotalBytes: Total memory available on the instance that ran the job.
- diskUsedBytes: Bytes of storage allocated to the AEE that are used by the filesystem.
- diskTotalBytes: Total bytes of disk space available to the job within the AEE.
- networkOutBytes: Total network bytes transferred out from AEE since the job started. Includes "dx upload" bytes.
- networkInBytes: Total network bytes transferred into AEE since the job started. Includes "dx download" bytes.
- diskReadBytes: Total bytes read from the AEE-accessible disks since the job started.
- diskWriteBytes: Total bytes written to the AEE-accessible disks since the job started.
- diskReadOpsCount: Total disk read operation count against AEE-accessible disk since the job started.
- diskWriteOpsCount: Total disk write operation count against AEE-accessible disk since the job started.

Note 1: cpuUsageUser, cpuUsageSystem, cpuUsageIowait, cpuUsageIdle and memoryUsedBytes metrics reflect usage by processes inside and outside of the AEE which include DNAnexus services responsible for proxying DNAnexus data.
Note 2: cpuUsageUser + cpuUsageSystem + cpuUsageIowait + cpuUsageIdle + cpuUsageSteal = 100. cpuUsageSteal is unreported, but can be derived from the other 4 quantities given that they add up to 100.
Note 3: cpuUsage numbers are rounded to 2 decimal places.
Note 4: networkOutBytes may be larger than job's egressReport which does not include "dx upload" bytes.

The format of METRICS job log lines is defined as follows using the example below:

2023-03-15 12:23:44 some-job-name METRICS ** CPU usr/sys/idl/wai: 24/11/1/64% (4 cores) * Memory: 1566/31649MB * Storage: 19/142GB * Net: 10↓/0↑MBps * Disk: r/w 20/174 MBps iops r/w 8/1300

"2023-03-15 12:23:44" is the metrics collection time.
"METRICS" is a type of job log line containing detailed job metrics.
"CPU usr/sys/idl/wai: 24/11/1/64%" maps to cpuUsageUser, cpuUsageSystem, cpuUsageIdle, cpuUsageIowait values.
"(4 cores)" maps to cpuCount.
"Memory: 1566/31649MB" maps to memoryUsedBytes and memoryTotalBytes.
"Storage: 19/142GB" maps to diskUsedBytes and diskTotalBytes.
"Net: 10↓/0↑MBps" is derived from networkOutBytes and networkInBytes cumulative totals by subtracting previous measurement from the measurement at the metric collection time, and dividing the difference by the time span between the two measurements.
"Disk: r/w 20/174 MBps iops r/w 8/1300" is derived similar to "Net:" from diskReadBytes, diskWriteBytes, diskReadOpsCount, and diskWriteOpsCount.r   )r   r  r  s        r   r   zMetricsHelpAction.__call__6  s    .U/	V` 	Ar   r  r  r   r   r   r,  r,  4  s    1r   r,  z--metrics-helpz.Print help for displaying detailed job metricsr  z,Configure SSH keys for your DNAnexus accountz:Configure SSH access credentials for your DNAnexus accountr  r  z,Command-line arguments to pass to ssh-keygenz--revokezmRevoke SSH public key associated with your DNAnexus account; you will no longer be able to SSH into any jobs.r  z Connect to a running job via SSHa	  Use an SSH client to connect to a job being executed on the DNAnexus platform. The job must be launched using "dx run --allow-ssh" or equivalent API options. Use "dx ssh_config" or the Profile page on the DNAnexus website to configure SSH for your DNAnexus account.zdx sshr  zName of job to connect tor  z0Command-line arguments to pass to the SSH clientz--no-firewall-updatezGDo not update the allowSSH allowed IP ranges before connecting with sshzConfigure the job to allow SSH access from an IP range, e.g. "--allow-ssh 1.2.3.4". If no argument is supplied then the client IP visible to the DNAnexus API server will be used by defaultz--suppress-running-checkr3  )r  rg  r  r  zTerminate jobs or analysesz&Terminate one or more jobs or analyseszdx terminatez$ID of a job or analysis to terminater   r   r  r4  zDelete a projectz-Delete projects and all their associated datazdx rmprojectzProjects to removez*Do not print purely informational messagesr   z#Create a new project or data objectzUse this command with one of the available subcommands (classes) to create a new project or data object from scratch.  Not all data types are supported.  See 'dx upload' for files and 'dx build' for applets.zdx newrR  r%  zCreate a new user accountzdx new userzUser optionsz-uz
--usernameUsername)rN  rg  z--emailzEmail addressz--firstz
First namez--middlezMiddle namez--lastz	Last namez--token-durationa  Time duration for which the newly generated auth token for the new user will be valid (default 30 days; max 30 days). An integer will be interpreted as seconds; you can append a suffix (s, m, h, d) to indicate different units (e.g. "--token-duration 10m" to indicate 10 minutes).z--occupation
Occupationz--on-behalf-ofz1On behalf of which org is the account provisionedzOrg optionszFOptionally invite the new user to an org with the specified parametersz--orgzIOrg membership level that will be granted to the new user; default MEMBER)r   r  r  rg  z--set-bill-toz^Set the default "billTo" field of the new user to the org; implies --allow-billable-activitiesz7Grant the new user "allowBillableActivities" in the orgz/Disable "appAccess" for the new user in the orgzHThe "projectAccess" to grant the new user in the org; default CONTRIBUTEz9Disable org invitation email notification to the new userzCreate new non-billable orgz[Create a new non-billable org. Contact sales@dnanexus.com for the creation of billable orgsz
dx new orgr;  zDescriptive name of the orgz--handlezxUnique handle for the org. The specified handle will be converted to lowercase and appended to "org-" to form the org IDzOrg membership level required to be able to list the members of the org, or to view the membership level or permissions of any other member of the org; default ADMIN)r  rg  r   zOrg membership level required to be able to change the billing account of an org-billed project to any other entity; default ADMINzCreate a new projectr  zName of the new projectz"Region affinity of the new projectz-sz--selectz0Select the new project as current after creatingzrID of the user or org to which the project will be billed. The default value is the billTo of the requesting user.z--phizAdd PHI protection to project)rg  r  r  z;Viewers on the project cannot access database data directlyz--monthly-compute-limitz*Monthly project spending limit for computez--monthly-egress-bytes-limitz4Monthly project spending limit for egress (in Bytes)z--monthly-storage-limitz*Monthly project spending limit for storagez--default-symlinkz,Default symlink for external storage accountz--drivez"Drive for external storage accountr  zCreate a new recordzdx new record)rg  r   rq  r  r  z--initz4Path to record from which to initialize all metadataz--closez.Close the record immediately after creating itzCreate a new workflowzdx new workflowzHPath to workflow or an analysis ID from which to initialize all metadatar'  zGet details of a data objectz&Get the JSON details of a data object.zdx get_detailsz,ID or path to data object to get details forr(  zSet details on a data objectz&Set the JSON details of a data object.zdx set_detailsz#ID or path to data object to modifyr  zJSON to store as detailsz--details-filez6Path to local file containing JSON to store as detailsr)  zSet visibility on a data objectz Set visibility on a data object.zdx set_visibilityr  r  z&Visibility that the object should haver*  zAdd types to a data objectzAdd types to a data object.  See https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types for a list of DNAnexus types.zdx add_typesr  r@  zTypes to add)r  r  rg  r+  zRemove types from a data objectzRemove types from a data object.  See https://documentation.dnanexus.com/developer/api/data-object-lifecycle/types for a list of DNAnexus types.zdx remove_typeszTypes to removez(Tag a project, data object, or executionzdx tagzTag a project, data object, or execution.  Note that a project context must be either set or specified for data object IDs or paths.z:ID or path to project, data object, or execution to modifyr  zTags to adduntagz*Untag a project, data object, or executionzdx untagzUntag a project, data object, or execution.  Note that a project context must be either set or specified for data object IDs or paths.zTags to remover/  zRename a project or data objecta  Rename a project or data object.  To rename folders, use 'dx mv' instead.  Note that a project context must be either set or specified to rename a data object.  To specify a project or a project context, append a colon character ":" after the project ID or name.z	dx renamez(Path to project or data object to renamer2  zNew namer0  z6Set properties of a project, data object, or executionzSet properties of a project, data object, or execution.  Note that a project context must be either set or specified for data object IDs or paths.zdx set_propertiesr  zpropertyname=valuez6Key-value pairs of property names and their new valuesr1  z8Unset properties of a project, data object, or executionzUnset properties of a project, data object, or execution.  Note that a project context must be either set or specified for data object IDs or paths.zdx unset_propertiespropertynamezProperty names to unsetr,  zClose data object(s)z-Close a remote data object or set of objects.zdx closezPath to a data object to closezWait for the object(s) to closer  z4Wait for data object(s) to close or job(s) to finisha  Polls the state of specified data object(s) or job(s) until they are all in the desired state.  Waits until the "closed" state for a data object, and for any terminal state for a job ("terminated", "failed", or "done").  Exits with a non-zero code if a job reaches a terminal state that is not "done".  Can also provide a local file containing a list of data object(s) or job(s), one per line; the file will be read if "--from-file" argument is added.zdx waitz;Path to a data object, job ID, or file with IDs to wait forz--from-filezCRead the list of objects to wait for from the file provided in path)r   r   r   r-  zADownload records, apps, applets, workflows, files, and databases.a  Download the contents of some types of data (records, apps, applets, workflows, files, and databases).  Downloading an app, applet or a workflow will attempt to reconstruct a source directory that can be used to rebuild it with "dx build".  Use "-o -" to direct the output to stdout.zdx get)r   r  r  r  r   rj  z Data object ID or name to accessa  local file path where the data is to be saved ("-" indicates stdout output for objects of class file and record). If not supplied, the object's name on the platform will be used, along with any applicable extensions. For app(let) and workflow objects, if OUTPUT does not exist, the object's source directory will be created there; if OUTPUT is an existing directory, a new directory with the object's name will be created inside it.zWhen downloading from a database, name of the file or folder to be downloaded. If omitted, all files in the database will be downloaded, so use caution and include the --allow-all-files argument.z--allow-all-filesz{When downloading from a database, this allows all files in a database to be downloaded when --filename argument is omitted.r  )r  rg  r  r  zWhen downloading from a database, look for files recursively down the directory structure. Otherwise, by default, only look on one level.z--no-extz>If -o is not provided, do not add an extension to the filenamez--omit-resourceszWWhen downloading an app(let), omit fetching the resources associated with the app(let).z%Overwrite the local file if necessaryr   z3Search functionality over various DNAnexus entitiesz4Search functionality over various DNAnexus entities.zdx find)rg  r   r  r  rK  r  zList available appszFinds apps subject to the given search parameters. Use --category to restrict by a category; common categories are available as tab completions and can be listed with --category-help.zName of the appz
--categoryzCategory of the appz--category-helpz%Print a list of common app categorieszReturn all versions of each appz--unpublishedzFReturn only unpublished apps (if omitted, returns only published apps)z--installedzReturn only installed appsz--billed-toz,User or organization responsible for the appz	--creatorzCreator of the app versionz--developerzDeveloper of the appz--created-aftera  Date (e.g. --created-after="2021-12-01" or --created-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-after=1642196636000) after which the app created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-after=-2d for apps created in the last 2 days)z--created-beforea  Date (e.g. --created-before="2021-12-01" or --created-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-before=1642196636000) before which the app was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-before=-2d for apps created earlier than 2 days ago)z--mod-aftera  Date (e.g. --mod-after="2021-12-01" or --mod-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --mod-after=1642196636000) after which the app modified. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --mod-after=-2d for apps modified in the last 2 days)z--mod-beforea  Date (e.g. --mod-before="2021-12-01" or --mod-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --mod-before=1642196636000) after which the app modified. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --mod-before=-2d for apps modified earlier than 2 days ago)globalworkflowszList available global workflowszFinds global workflows subject to the given search parameters. Use --category to restrict by a category; common categories are available as tab completions and can be listed with --category-help.zName of the workflowzCategory of the workflowz1Print a list of common global workflow categoriesz$Return all versions of each workflowzPReturn only unpublished workflows (if omitted, returns only published workflows)z1User or organization responsible for the workflowzCreator of the workflow versionzDeveloper of the workflowa  Date (e.g. --created-after="2021-12-01" or --created-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-after=1642196636000) after which the workflow was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-after=-2d for workflows created in the last 2 days).a  Date (e.g. --created-before="2021-12-01" or --created-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-before=1642196636000) before which the workflow was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-before=-2d for workflows created earlier than 2 days ago)a  Date (e.g. --mod-after="2021-12-01" or --mod-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --mod-after=1642196636000) after which the workflow was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --mod-after=-2d for workflows modified in the last 2 days)a  Date (e.g. --mod-before="2021-12-01" or --mod-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --mod-before=1642196636000) before which the workflow was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --mod-before=-2d for workflows modified earlier than 2 days ago)jobsz List jobs in the current projectzFinds jobs subject to the given search parameters. By default, output is formatted to show the last several job trees that you've run in the current project.resolvezdx find jobs)rg  r   rq  r  conflict_handlerr  r  )r  r  analysesz$List analyses in the current projectzFinds analyses subject to the given search parameters. By default, output is formatted to show the last several job trees that you've run in the current project.zdx find analysesr	  r5  z:List executions (jobs and analyses) in the current projectzFinds executions (jobs and analyses) subject to the given search parameters. By default, output is formatted to show the last several job trees that you've run in the current project.zdx find executionsz(List data objects in the current projectzFinds data objects subject to the given search parameters. By default, restricts the search to the current project if set. To search over all projects (excluding public projects), use --all-projects (overrides --path and --norecurse).zdx find dataz--classr  )r  r   r  r   rj  zData object classz&{record,file,applet,workflow,database})r  r   rg  r  z--state)r$  closingro  r=  zState of the objectz--visibility)r  r  eitherz#Whether the object is hidden or notzMSearch criteria for the object name, interpreted according to the --name-modez--name-moder  zName mode to use for searching)r  exactregexpz--typezType of the data objectz--linkz'Object ID that the data object links toz--all-projectsz--allprojectsz9Extend search to all projects (excluding public projects)z6Project and/or folder in which to restrict the resultszPROJECT:FOLDER)rg  r  z--norecurser  zDo not recurse into subfoldersa  Date (e.g. --created-after="2021-12-01" or --created-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-after=1642196636000) after which the object was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-after=-2d for objects created in the last 2 days).a  Date (e.g. --created-before="2021-12-01" or --created-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-before=1642196636000) before which the object was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-before=-2d for objects created earlier than 2 days ago)a  Date (e.g. --mod-after="2021-12-01" or --mod-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --mod-after=1642196636000) after which the object was modified. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --mod-after=-2d for objects modified in the last 2 days)a  Date (e.g. --mod-before="2021-12-01" or --mod-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --mod-before=1642196636000) before which the object was modified. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --mod-before=-2d for objects modified earlier than 2 days ago)z*Restrict the search to the provided regionzList projectsziFinds projects subject to the given search parameters. Use the --public flag to list all public projects.zdx find projectszName of the projecta  Date (e.g. --created-after="2021-12-01" or --created-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-after=1642196636000) after which the project was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-after=-2d for projects created in the last 2 days).a  Date (e.g. --created-before="2021-12-01" or --created-before="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-before=1642196636000) before which the project was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-before=-2d for projects created earlier than 2 days ago)zIf set to true, only externalUploadRestricted projects will be retrieved. If set to false, only projects that are not externalUploadRestricted will be retrieved.z$List entities within a specific org.z8"dx find org members" lists members in the specified orgzA"dx find org projects" lists projects billed to the specified orgz9"dx find org apps" lists apps billed to the specified orgz5Please execute "dx find org -h" for more information.zdx find orgmembersz!List members in the specified orgzIFinds members in the specified org subject to the given search parameterszdx find org memberszOrg IDzRRestrict the result set to contain only members at the specified membership level.z)List projects billed to the specified orgzFinds projects billed to the specified org subject to the given search parameters. You must be an ADMIN of the specified org to use this command. It allows you to identify projects billed to the org that have not been shared with you explicitly.zdx find org projectszName of the projectsz--idszGPossible project IDs. May be specified like "--ids project-1 project-2"z--public-onlyr  zInclude only public projects)r  rg  r  r  z--private-onlyzInclude only private projects)r   r   z%List apps billed to the specified orgzFinds apps billed to the specified org subject to the given search parameters. You must be an ADMIN of the specified org to use this command. It allows you to identify apps billed to the org that have not been shared with you explicitly.zdx find org appszName of the appsz;Return only unpublished apps (if omitted, returns all apps)a  Date (e.g. --created-after="2021-12-01" or --created-after="2021-12-01 19:01:33") or integer Unix epoch timestamp in milliseconds (e.g. --created-after=1642196636000) after which the app was created. You can also specify negative numbers to indicate a time period in the past suffixed by s, m, h, d, w, M or y to indicate seconds, minutes, hours, days, weeks, months or years (e.g. --created-after=-2d for apps created in the last 2 days).a  Date (e.g. 2012-01-01) or integer timestamp after which the app was last modified (negative number means seconds in the past, or use suffix s, m, h, d, w, M, y) 
                                                         Negative input example "--mod-after=-2d"a  Date (e.g. 2012-01-01) or integer timestamp before which the app was last modified (negative number means seconds in the past, or use suffix s, m, h, d, w, M, y) 
                                                          Negative input example "--mod-before=-2d")r   r   orgsz	List orgsz2Finds orgs subject to the given search parameters.zdx find orgszuRestrict the result set to contain only orgs in which the requesting user has at least the specified membership level)r   rN  rg  z--with-billable-activitieszRestrict the result set to contain only orgs in which the requesting user can perform billable activities; mutually exclusive with --without-billable-activitiesz--without-billable-activitieswith_billable_activitieszRestrict the result set to contain only orgs in which the requesting user **cannot** perform billable activities; mutually exclusive with --with-billable-activities)r  r=  )run_notebooknotebookz&Launch a web notebook inside DNAnexus.zdx notebooknotebook_typezType of notebook to launch)jupyter_labjupyter_notebookjupyterz--notebook_filesz%Files to include on notebook instancer  z--sparkzInstall spark infrastructure.z)local port to use to access the notebook.2001z
--snapshotz(A snapshot file to reform on the server.z,How long to keep the notebook open (smhwMy).1hzDo not launch web browser.open_serverz+What version of the notebook app to launch.z--instance-typez%Instance type to run the notebook on.mem1_ssd1_x4z--only_check_configz'Only check SSH config do not launch app)ssh_config_check)r  r  )	run_loupezloupe-viewerz1Launch the Loupe viewer for 10x data on DNAnexus.zdx loupe-viewerloupe_filesz Files to include in loupe viewerz-local port to use to access the Loupe viewer.z0How long to keep the Loupe viewer open (smhwMy).z)Instance type to run the Loupe viewer on.r  zCall an API methodzCall an API method directly.  The JSON response from the API server will be returned if successful.  No name resolution is performed; DNAnexus IDs must always be provided.  The API specification can be found ata  

https://documentation.dnanexus.com/developer/api

EXAMPLE

  In the following example, a project's description is changed.

  $ dx api project-B0VK6F6gpqG6z7JGkbqQ000Q update '{"description": "desc"}'
  {
      "id": "project-B0VK6F6gpqG6z7JGkbqQ000Q"
  }

zdx apir&  zOne of "system", a class name (e.g. "record"), or an entity ID such as "record-xxxx".  Use "app-name/1.0.0" to refer to version "1.0.0" of the app named "name".ir'  zCMethod name for the resource as documented by the API specificationr"  z{}z6JSON input for the method (if not given, "{}" is used)z--inputz0Load JSON input from FILENAME ("-" to use stdin)rh  zAGenerate a batch plan (one or more TSV files) for batch executionzTGenerate a table of input files matching desired regular expressions for each input.zdx generate_batch_inputsr#  zAn input to be batch-processed "-i<input name>=<input pattern>" where <input_pattern> is a regular expression with a group corresponding to the desired region to match (e.g. "-iinputa=SRR(.*)_1.gz" "-iinputb=SRR(.*)_2.gz")zLProject and/or folder to which the search for input files will be restricted)rg  r  r  z--output_prefixzPrefix for output filedx_batchz#Publish an app or a global workflowzQRelease a version of the executable (app or global workflow) to authorized users.z
dx publishzAID or name and version of an app/global workflow, e.g. myqc/1.0.0z--no-defaultz5Do not set a "default" alias on the published versionrm  r  zRequests for the specified set files or for the files in a single specified folder in one project to be archived on the platforma1  
Requests for {} or for the files in {} in {} to be archived on the platform.
For each file, if this is the last copy of a file to have archival requested, it will trigger the full archival of the object. 
Otherwise, the file will be marked in an archival state denoting that archival has been requested.
zthe specified set filesza single specified folderzONE projecta%  
The input paths should be either 1 folder path or up to 1000 files, and all path(s) need to be in the same project. 
To specify which project to use, prepend the path or ID of the file/folder with the project ID or name and a colon. 

EXAMPLES:

    # archive 3 files in project "FirstProj" with project ID project-B0VK6F6gpqG6z7JGkbqQ000Q
    $ dx archive FirstProj:file-B0XBQFygpqGK8ZPjbk0Q000Q FirstProj:/path/to/file1 project-B0VK6F6gpqG6z7JGkbqQ000Q:/file2
    
    # archive 2 files in current project. Specifying file ids saves time by avoiding file name resolution.
    $ dx select FirstProj
    $ dx archive file-A00000ygpqGK8ZPjbk0Q000Q file-B00000ygpqGK8ZPjbk0Q000Q

    # archive all files recursively in project-B0VK6F6gpqG6z7JGkbqQ000Q
    $ dx archive project-B0VK6F6gpqG6z7JGkbqQ000Q:/
  z
dx archivez--all-copiesr  zNIf true, archive all the copies of files in projects with the same billTo org.r   zzSee https://documentation.dnanexus.com/developer/api/data-containers/projects#api-method-project-xxxx-archive for details.)r  rg  r  r  zDo not ask for confirmation.z--no-recursezWhen `path` refers to a single folder, this flag causes only files in the specified folder and not its subfolders to be archived. This flag has no impact when `path` input refers to a collection of files.zJMay refer to a single folder or specify up to 1000 files inside a project.OutputzKIf -q option is not specified, prints "Tagged <count> file(s) for archival")r~  r   r{  )r  r  	unarchivezRequests for the specified set files or for the files in a single specified folder in one project to be unarchived on the platform.z
Requests for {} or for the files in {} in {} to be unarchived on the platform.
The requested copy will eventually be transitioned over to the live state while all other copies will move over to the archival state.
za specified set filesa.  
The input paths should be either 1 folder path or up to 1000 files, and all path(s) need to be in the same project. 
To specify which project to use, prepend the path or ID of the file/folder with the project ID or name and a colon.

EXAMPLES:

    # unarchive 3 files in project "FirstProj" with project ID project-B0VK6F6gpqG6z7JGkbqQ000Q 
    $ dx unarchive FirstProj:file-B0XBQFygpqGK8ZPjbk0Q000Q FirstProj:/path/to/file1 project-B0VK6F6gpqG6z7JGkbqQ000Q:/file2
 
    # unarchive 2 files in current project. Specifying file ids saves time by avoiding file name resolution.
    $ dx select FirstProj
    $ dx unarchive file-A00000ygpqGK8ZPjbk0Q000Q file-B00000ygpqGK8ZPjbk0Q000Q

    # unarchive all files recursively in project-B0VK6F6gpqG6z7JGkbqQ000Q
    $ dx unarchive project-B0VK6F6gpqG6z7JGkbqQ000Q:/
  zdx unarchivez--ratez<The speed at which all files in this request are unarchived.z&- Azure regions: {Standard, Expedited})r  ri  z- AWS regions: {Standard, Bulk})	ExpeditedStandardBulkrO  zWhen `path` refers to a single folder, this flag causes only files in the specified folder and not its subfolders to be unarchived. This flag has no impact when `path` input refers to a collection of files.zfIf -q option is not specified, prints "Tagged <> file(s) for unarchival, totalling <> GB, costing <> "r}  r   a/  Retrieves the data or generates SQL to retrieve the data from a dataset or cohort for a set of entity.fields. Additionally, the dataset's dictionary can be extracted independently or in conjunction with data. Listing options enable enumeration of the entities and their respective fields in the dataset.a  Retrieves the data or generates SQL to retrieve the data from a dataset or cohort for a set of entity.fields. Additionally, the dataset's dictionary can be extracted independently or in conjunction with data. Provides listing options for entities and fields.zdx extract_datasetzv3.0 Dataset or Cohort object ID (project-id:record-id where "record-id" indicates the record ID in the currently selected project) or namez-dddz--dump-dataset-dictionaryas  If provided, the three dictionary files, <record_name>.data_dictionary.csv, <record_name>.entity_dictionary.csv, and <record_name>.codings.csv will be generated. Files will be comma delimited and written to the local working directory, unless otherwise specified using --delimiter and --output arguments. If stdout is specified with the output argument, the data dictionary, entity dictionary, and coding are output in succession, without separators. If any of the three dictionary files does not contain data (i.e. the dictionary is empty), then that particular file will not be created (or be output if the output is stdout).z--fieldsaf  A comma-separated string where each value is the phenotypic entity name and field name, separated by a dot. For example: "<entity_name>.<field_name>,<entity_name>.<field_name>". Internal spaces are permitted. If multiple entities are provided, field values will be automatically inner joined. If only the --fields argument is provided, data will be retrieved and returned. If both --fields and --sql arguments are provided, a SQL statement to retrieve the specified field data will be automatically generated and returned. Alternatively, use --fields-file option when the number of fields to be retrieved is large.z--fields-filea(  A file with no header and one entry per line where every entry is the phenotypic entity name and field name, separated by a dot. For example: <entity_name>.<field_name>. If multiple entities are provided, field values will be automatically inner joined. If only the --fields-file argument is provided, data will be retrieved and returned. If both --fields-file and --sql arguments are provided, a SQL statement to retrieve the specified field data will be automatically generated and returned. May not be used in conjunction with the argument --fields.z--sqlzIf provided, a SQL statement (string) will be returned to query the set of entity.fields, instead of returning stored values from the set of entity.fieldsz--delimz--delimiterr  zAlways use exactly one of DELIMITER to separate fields to be printed; if no delimiter is provided with this flag, COMMA will be used)r  r  r  rg  zLocal filename or directory to be used ("-" indicates stdout output). If not supplied, output will create a file with a default name in the current folderz--list-fieldsu  List the names and titles of all fields available in the dataset specified. When not specified together with "–-entities", it will return all the fields from the main entity. Output will be a two column table, field names and field titles, separated by a tab, where field names will be of the format, "<entity name>.<field name>" and field titles will be of the format, "<field title>".z--list-entitieszList the names and titles of all the entities available in the dataset specified. Output will be a two column table, entity names and entity titles, separated by a tab.z
--entitieszSimilar output to "--list-fields", however using "--entities" will allow for specific entities to be specified. When multiple entities are specified, use comma as the delimiter. For example: "--list-fields --entities entityA,entityB,entityC"extract_assayzRetrieve the selected data or generate SQL to retrieve the data from a genetic variant or somatic assay in a dataset or cohort based on provided rules.zdx extract_assaygermlinezQuery a Dataset or Cohort for an instance of a germline variant assay and retrieve data, or generate SQL to retrieve data, as defined by user-provided filters.)rg  r   zv3.0 Dataset or Cohort object ID (project-id:record-id, where ":record-id" indicates the record-id in the currently selected project) or name.z--assay-namezSpecify the genetic variant assay to query. If the argument is not specified, the default assay used is the first assay listed when using the argument, "--list-assays."z--list-assayszZList genetic variant assays available for query in the specified Dataset or Cohort object.z--retrieve-alleleu  A JSON object, either in a file (.json extension) or as a string (‘<JSON object>’), specifying criteria of alleles to retrieve. Returns a list of allele IDs with additional information. Use --json-help with this option to get detailed information on the JSON format and filters)r@  r  r  r  rg  z--retrieve-annotationu   A JSON object, either in a file (.json extension) or as a string (‘<JSON object>’), specifying criteria to retrieve corresponding alleles and their annotation. Use --json-help with this option to get detailed information on the JSON format and filters.z--retrieve-genotypeu<  A JSON object, either in a file (.json extension) or as a string (‘<JSON object>’), specifying criteria of samples to retrieve. Returns a list of genotypes and associated sample IDs and allele IDs. Genotype types "ref" and "no-call" have no allele ID, and "half" types where the genotype is half reference and half no-call also have no allele ID. All other genotype types have an allele ID, including "half" types where the genotype is half alternate allele and half no-call. Use --json-help with this option to get detailed information on the JSON format and filters.z--infer-nocalla   When using the "--retrieve-genotype" option, infer genotypes with type "no-call" if they were excluded when the dataset was created. This option is only valid if the exclusion parameters at ingestion were set to "exclude_nocall=true", "exclude_halfref=false", and "exclude_refdata=false".z--infer-refa  When using the "--retrieve-genotype" option, infer genotypes with type "ref" if they were excluded when the dataset was created. This option is only valid if the exclusion parameters at ingestion were set to "exclude_nocall=false", "exclude_halfref=false", and "exclude_refdata=true".z--json-helpzIf the flag is provided, a SQL statement, returned as a string, will be provided to query the specified data instead of returning data.zA local filename or directory to be used, where "-" indicates printing to STDOUT. If -o/--output is not supplied, default behavior is to create a file with a constructed name in the current folder.somaticzQuery a Dataset or Cohort for an instance of a somatic variant assay and retrieve data, or generate SQL to retrieve data, as defined by user-provided filters.zZList somatic variant assays available for query in the specified Dataset or Cohort object.z--retrieve-meta-infoz`List meta information, as it exists in the original VCF headers for both INFO and FORMAT fields.z--retrieve-variantu  A JSON object, either in a file (.json extension) or as a string (‘<JSON object>’), specifying criteria of somatic variants to retrieve. Retrieves rows from the variant table, optionally extended with sample and annotation information (the extension is inline without affecting row count). By default returns the following set of fields; "assay_sample_id", "allele_id", "CHROM", "POS", "REF", and "allele". Additional fields may be returned using --additional-fields. Use --json-help with this option to get detailed information on the JSON format and filters. When filtering, the user must supply one, and only one of "location", "annotation.symbol", "annotation.gene", "annotation.feature", "allele.allele_id".z--additional-fields-helpz%List all fields available for output.z--include-normal-samplezInclude variants associated with normal samples in the assay. If no flag is supplied, variants from normal samples will not be supplied.z--additional-fieldsa  A set of fields to return, in addition to the default set; "assay_sample_id", "allele_id", "CHROM", "POS", "REF", "allele". Fields must be represented as field names and supplied as a single string, where each field name is separated by a single comma. For example, "fieldA,fieldB,fieldC."  Internal spaces are permitted.  Use --additional-fields-help with this option to get detailed information and the full list of output fields available.zSpecify the somatic variant assay to query. If the argument is not specified, the default assay used is the first assay listed when using the argument, "--list-assays."
expressionzRetrieve the selected data or generate SQL to retrieve the data from a molecular expression assay in a dataset or cohort based on provided rules.zv3.0 Dataset or Cohort object ID, project-id:record-id, where ":record-id" indicates the record-id in current selected project, or name)r  r@  rg  z^List molecular expression assays available for query in the specified Dataset or Cohort objectz--retrieve-expressiona  A flag to support, specifying criteria of molecular expression to retrieve. Retrieves rows from the expression table, optionally extended with sample and annotation information where the extension is inline without affecting row count. By default returns the following set of fields; "sample_id", "feature_id", and "value". Additional fields may be returned using "--additional-fields". May be used with either "--filter-json" or "--filter-json-file". Specify "--json-help" following this option to get detailed information on the json format and filters. When filtering, one, and only one of "location", "annotation.feature_id", or "annotation.feature_name" may be supplied. If a Cohort object is supplied, returned samples will be initially filtered to match the cohort-defined set of samples, and any additional filters will only further refine the cohort-defined set. If no filter is provided, a SQL query returning all data will be generated. In this case, the --sql parameter must be used.zSpecify a specific molecular expression assay to query. If the argument is not specified, the default assay used is the first assay listed when using the argument, "--list-assays"z--filter-jsonz-jaJ  The full input JSON object as a string and corresponding to "--retrieve-expression". Must be used with "--retrieve-expression" flag. Either "--filter-json" or "--filter-json-file" may be supplied, not both. If no filter is provided, a SQL query returning all data will be generated. In this case, the --sql parameter must be used.z--filter-json-fileaH  The full input JSON object as a file and corresponding to "--retrieve-expression". Must be used with "--retrieve-expression" flag. Either "--filter-json" or "--filter-json-file" may be supplied, not both. If no filter is provided, a SQL query returning all data will be generated. In this case, the --sql parameter must be used.zcWhen set, return a json template of "--retrieve-expression" and a list of filters with definitions.a%  If the flag is provided, a SQL statement (as a string) will be returned for the user to further query the specified data, instead of returning actual data values. If used without a json filter, returns all data. Use of "--sql" is not supported when also using the flag, --expression-matrix/-emaW  A set of fields to return, in addition to the default set; "sample_id", "feature_id", and "value".  Fields must be represented as field names and supplied as a single string, where each field name is separated by a single comma. For example, fieldA,fieldB,fieldC. Use "--additional-fields-help" to get the full list of output fields available.z--expression-matrixz-ema  If the flag is provided with "--retrieve-expression", the returned data will be a matrix of sample IDs (rows) by feature IDs (columns), where each cell is the respective pairwise value. The flag is not compatible with "--additional-fields". Additionally, the flag is not compatible with an "expression" filter. If the underlying expression value is missing, the value will be empty in returned data. Use of --expression-matrix/-em is not supported when also using the flag, "--sql".c                 &    | dk(  rdS t        |       S )Nz\trL  )r   )r  s    r   r8  r8    s    1:4 3q6 r   a  Always use exactly one of DELIMITER to separate fields to be printed; if no delimiter is provided with this flag, COMMA will be used. If a file is specified and no --delim argument is passed or is COMMA, the file suffix will be ".csv". If a file is specified and the --delim argument is TAB, the file suffix will be ".tsv". Otherwise, if a file is specified and "--delim" is neither COMMA or TAB file suffix will be ".txt".zA local filename to be used, where "-" indicates printing to STDOUT. If -o/--output is not supplied, default behavior is to create a file with a constructed name in the current folder.r   znGenerates a new Cohort object on the platform from an existing Dataset or Cohort object and using list of IDs.zdx create_cohort)rg  r   r  rq  r  zDNAnexus path for the new data object. If not provided, default behavior uses current project and folder, and will name the object identical to the assigned record-id.)rN  r@  rg  z--cohort-idsa  A set of IDs used to subset the Dataset or Cohort object as a comma-separated string. IDs must match identically in the supplied Dataset. If a Cohort is supplied instead of a Dataset, the intersection of supplied and existing cohort IDs will be used to create the new cohort.z--cohort-ids-filea$  A set of IDs used to subset the Dataset or Cohort object in a file with one ID per line and no header. IDs must match identically in the supplied Dataset. If a Cohort is supplied instead of a Dataset, the intersection of supplied and existing cohort IDs will be used to create the new cohort.zReturn the docstring and exitrg  rd  r   z1Display help messages and dx commands by categoryzDisplays the help message for the given command (and subcommand if given), or displays the list of all commands in the given category.z

CATEGORIES

  z

EXAMPLE

  zyTo find all commands related to running and monitoring a job and then display the help message for the command "run", runr  zq

  $ dx help exec
    <list of all execution-related dx commands>
  $ dx help run
    <help message for dx run>
zdx helpr  zlDisplay the help message for the given command, or the list of all available commands for the given categoryr  z@Display the help message for the given subcommand of the commandizhelp runc            
      2   dt         j                  v rMdd l} t        j                  j
                  }| j                  t        dddgdt         j                  v r|nd        t        t              dkD  rt        j                  t              }t        xj                  dj                  t        j                  t        |d	d
            z  c_        t!        |       t#        |       t%        |       t'        |d      s2t        j                  t        dgz          t        j(                  d       	 |j+                  |       t        j                  j-                          y t        j1                          t        j(                  d       y #  t/                Y y xY w)Nr   r   Fgtabler   _DX_ARC_DEBUG)always_complete_optionsexcludeoutput_streamz {prog}-{command}r  r   )r  r  r  r   r   )r_  r`  argcompleter   r   r  autocompleter  r=  r  r  r?  
USER_AGENTr  r  r  r   r   r/   hasattrr  r  r  rJ   rn  )r\  r[  r   s      r   mainr`    s-   # 

))  9>*2H)=@OSUS]S]@]}cg 	! 	i
 9~  +.556;;PWX\^gikPl5mmt$$tV$ i8*45HHQK	IIdOJJ 			Js   ./F F__main__r  rv  )r   NrO  )N)r   T(  
__future__r   r   r   r   r_  r   r  rc  re  rX  r   r  r  r  r  r+  r  r  r  	functoolsr  basicConfigr  compatr
   r   r?  dxpy.scriptsr   r   dxpy.exceptionsr   r   r   r   clir   r   r   r   workflow_clicli.cpr   cli.dataset_utilitiesr   r   r   r   r   cli.downloadr   r   r   cli.parsersr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   cli.exec_ior>   r?   cli.orgr@   rA   rB   rC   rD   rE   rF   rG   rH   rI   
exceptionsrJ   rK   rL   rM   rN   rO   utilsrP   rQ   rR   rS   rT   utils.batch_utilsrU   rV   app_categoriesrW   utils.printingrX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   utils.pretty_printrm   rn   utils.resolverro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   utils.completerr   r   r   r   r   r   utils.describer   r   r   r   r   r   r   r   r   r  r   urllib.parser   coloramar  r`  old_term_settingr	  gnureadlinereadlineImportErrorr  r;  r   r   r   rm  parser_categories_sortedr  r   r   r   r   r   r   r  r   r   r  r  r   r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r5  r:  r>  r  rL  r$  r  r  r%  r4  r&  r  r.  r  r  r  r  r!  r)  r'  r(  r*  r+  rA  rE  r/  r0  r1  r^  rh  ru  r  r  r  r  r  r-  r"  r  r!  r  rP  r  r  r*  rC  r  r[  r_  rc  r@  r  rk  r,  r  r  r  r  r  r  r  r  r  r  r  r8  r9  r  r  r  r\  r  r  r  r  r  r  r  r  r  r  rh  r  r  rn  r  Actionr  r  r  r  r  r  ArgumentParserr  r  r  r  API_VERSIONr  RawTextHelpFormatterr  add_argumentadd_subparsersSUPPRESSr   r  
add_parserparser_loginhost_actionr  port_actionprotocol_actionrg  set_defaultsparser_logoutparser_exitparser_whoami
parser_envparser_setenvparser_clearenvparser_inviteparser_uninvite	parser_lsadd_mutually_exclusive_groupls_output_argsls_path_action	completerparser_treetree_path_action
parser_pwdparser_selectselect_project_action	parser_cdcd_path_action	parser_cpcp_sources_action	parser_mvmv_sources_actionparser_mkdirmkdir_paths_actionparser_rmdirrmdir_paths_action	parser_rmrm_paths_actionparser_describedescribe_path_actionparser_uploadupload_filename_actionr   parser_downloadparser_download_paths_argparser_make_download_urlpath_action
parser_catcat_path_actionparser_headhead_path_actionr  add_argument_groupapp_and_globalworkflow_optionsapplet_and_workflow_optionsnextflow_optionssrc_dir_action	REMAINDERasset_builderr  parser_build_asset
parser_addsubparsers_addparser_add_usersparser_add_developersparser_add_stageadd_stage_folder_args	add_stageparser_add_memberparser_listsubparsers_listparser_list_usersparser_list_developersparser_list_stageslist_stagesparser_list_databasesubparsers_list_databaseparser_list_database_filesparser_removesubparsers_removeparser_remove_usersparser_remove_developersparser_remove_stageremove_stageparser_remove_memberparser_updatesubparsers_updateparser_update_orgupdate_job_reuse_argsparser_update_workflowupdate_workflow_title_args"update_workflow_output_folder_argsupdate_workflowparser_update_stageupdate_stage_name_argsupdate_stage_folder_argsupdate_stageparser_update_memberparser_update_projectr   allowed_executables_group!database_results_restricted_groupparser_installinstall_app_actionparser_uninstalluninstall_app_action
parser_runrun_executable_actionr  	ic_formatr  r  preserve_outputsr  parser_watch_trygroupr,  parser_ssh_config
parser_sshparser_ssh_firewallparser_terminater>  r  r  parser_rmprojectprojects_action
parser_newsubparsers_newparser_new_userparser_new_user_user_optsparser_new_user_org_optsparser_new_orgr  parser_new_recordinit_actionparser_new_workflownew_workflowparser_get_detailsparser_set_detailsparser_set_visibilityparser_add_typesparser_remove_types
parser_tagparser_untagparser_renameparser_set_propertiesparser_unset_propertiesparser_closeparser_wait
parser_getparser_findsubparsers_findparser_find_appsparser_find_globalworkflowsparser_find_jobsparser_find_analysesparser_find_executionsparser_find_dataparser_find_projectsparser_find_orgsubparsers_find_orgparser_find_org_membersparser_find_org_projectsfind_org_projects_publicparser_find_org_appsparser_find_orgs)parser_find_orgs_with_billable_activitiesssh_tunnel_app_supportr>  parser_notebookrx  notebook_with_ssh_config_checkrI  parser_loupe_viewer
parser_apiparser_generate_batch_inputsparser_publishparser_archiveparser_archive_outputparser_unarchiveparser_extract_datasetparser_extract_assaysubparsers_extract_assayparser_extract_assay_germlineparser_e_a_g_mutex_group"parser_e_a_g_infer_new_mutex_groupparser_extract_assay_somaticparser_e_a_s_mutex_groupparser_extract_assay_expressionparser_create_cohortparser_create_c_mutex_grouprl  category_listr  rK  sortr`  r   )rK  s   0r   <module>r5     sSr  ( S R B  B  B  B  B  B  B  B 
   ',, ' -  % ! X X : : *  L  L T T         LV V V, , , ` ` > +X X X X X X ;Y Y Y Y Y Y Y
> >n n n 8!$	HMMO #i  RZZBJJv$6$A$A'$J!zz&1!(BJJv	* !1BJJv 	 
k %7%'))F)+!-$W$&(&K&(**i)+"-*G*,".&W&(*%I%')'M')+!, *   M(- -, +**, , &8%%' & HHQRL	 
RZZF+f4BJJvBJJv] ]~C)J;.# >@9#*(%GN2J(U$;	#16)L\*:Sj1hNb)Vnb6H2%P D,",\**!F!F4 D!H26:5"	M_ (zT#cJ(V@#, E <|UnCL'*:.i"$%N#JQh


]
"H
288vFR\hBH1hN2`y(vR:.xT=KZAXF(gRR8)hoo )8?? DHOO DX__  22X__ 2,%Kx.. %KPF, 
mogkgwgwy}  zN  zN  9O  'O  RX  'X  [_  `t  [u  'u  xb  'b  ei  jf  eg  'g  jp  'p  sw  xJ  sK  'K  NC  'C*2*G*G#+* G
I   KaFn  o""(9(9	"J

 
 $$W3i 2V*4xj % J   )*G  H''7v'w''s  BA'  B++L  @i  sz+  {=E=N=N N  N;#o&:   .z@ajw  x   ()i!-  /   +um  o   +QX5F5F}  ]   %e  4  3
 %%h+K2R+6/7j	 & :
   8*k  l   8#4u  v   <  /X  bi   j     ' ) 4
 ##F1T0SZc $ e   j  ) 	 2
 %%h5]3P+6/7j	 & :
   6(KT`gp  q     ' ) 4
 ""5/W/3  5D  0E  H@  0@3;3P3PW_,4: # 7
   t,p  DG  (H+  - 
  40m  AD  ,E+  - 
  S  ! 
y 1
 %%h+W2t+6 & 8   >
Abkx  y   8  +B".  0   ;  .^".  0     ' ' 2
 ''
9e 5  FS ( T   Y  .C$0  2   (  > I 6
 %%h+_ 3q+6/7j	 & :
   9+=  >   9+MWZbe  f   7)W#Q[ail  n   <l=W   A     ' ' 2
 ''
-f 5O-:19
	 ( <
   X,@  A   Y-Q[^fi  j   (  + G 4
 !!$-V.W+7Hk*Z'. " 0	 
  tW+>|  T779   D(AV_k  l 	  w%8  N 	  {)<\  R 	  x&B<  X''  6N.13 ( @*,  	  B   	d +
 ##F1U0T-98,D)2 $ 4   w-@  V   x.IR^  _++F  :R25s , D ,h?     d  #  -
 ""5/P/P(0,4: # 7
   S  ! 
t ,
 %%h5] 3q+6/7j & : &229  D[9<d 3 L "19[`"a     8*]  ^   9.\ GQ]  _   :,s".  0   U  3 $ /
 !!$-S.T[b+3* " 6	 ''c3 .l ( m*H=  	  B   	d +
 !!$-e2:2O2O.2  4r  /s v / 	  U  hj  ~B  	C	/CF	/ (/+3W*= " ?	 **9;`jr14 + 6 -/   	  }4  1K  ^a  ,b   c 	  1  9L  Ua  kp   q 	  B   	d +
 !!$-e2:2O2O.2  4z  /{'.+3W*=	 " ?	
 **9;`jr14 + 6 -/   	  }4  1F  Y\  ,]   ^ 	  1  9K  T`  jo   p 	  B   	d +
 $$W3H1FZ.6Z % 9   $2m!-  /!..w=Yciqt.u .A     u  %  .
 $$W3D1B.6Z % 9 "..w=Yciqt.u .A     u  %  .
 !!$-N.PW^+3W*= " ?	 ((7HRX`c(d+-  	  t]1KT`  a 	  tY-El  [ 	  B   	d + ''
9S48  :s  5t  wI  5I  LP  QM  LN  5N  QY  5Y  \`  aQ  \R  5R8@8U8U19<T\0]-:	 ( <
   [/PYe  f   [/LUa  b   X,Ybn  o   YT  3^  qt  .u$0  2   Wc	"&  (a  tw  #x  y '33F  GR  eh  Bi3  j !0!2     (  + ,@ A
 %%h5R 3Z/E{T\.]+6 & 8 '33Jc :y 4 z #1#3      4(2C2C  D   8_ $  &D  WZ  ![!$  &   45U^j  k   8*T]i  j   ?1MTc"/9J9J9L  N   ?1W^q  r   +2SZhq}  ~   U  3 & 1
 ''
9K 5^-:19
 ( < ,88Gv?BF 9 T &5vh&G  #   T:  5{   |   T=  8J  S_   `   T=7U^j  k   T71l$0  2   _3OVe$13::;L;L;N  P   _3g$0  2   2  :D"2%'  )   [/n"0  G   /  2 F 3
 &001DKt >X6L 1 N  '33F  Bl3  m'9   % %l  :d %  e  % %l  :W %  X  % %+< % = (V <
 ""5/Hx,4: # 7
))&7^fi)j+VH=  
  *i+L  B 
  S  ! 
v .
 ##F)?0y-98,D)2	 $ 4
   ysCFl!#  %++F9T+U ,fX>     d  #  /
 $$W3[ 2z  }A  BQ  }R  2R  Uc  2c*4.6-D % F
 ".!@!@Ao  rN  "O *==>i  lL  M 223Z  ]H  I    + 3f (	  )
   , 4D (  ) **9  <v  ~A*  B)+    '>8HQ^eksx  y   +(2C2CM`fnv  w   ,(;BV_lsy  BL   M   ,.GNir  GM  Ue   f  ( (  F{  EH (  I   %  (   +t  3@  IU  \e   f   .x/@/@]f  g  + +E + :  + +K  ?B  KW' , )  + +NARAR[hox + y4CXV`La4b  + +H  <L& , ((1     '   *  ,K  T`  go   p   ,  .o  xE  LS   T   -h.?.?\d  e  ( (}  D{#/ ) @  ( ({  Bz#/ ) @   $  3f  pt+Y  @  + +D+  EX!%I} , N   t  ,   *1B1B<^l  m   -  5O  Xe  lz   {  + +$ + G  + +,EHL]L]fr  zQ +  R  + +,H  PQ  Zg  nE +  F  + +4 + 8  + +JX=N=NWcjr + s  + +M  AD  MZ  ai +  j   ;(BSBS\i  qE  MR   S   7h>O>OXe  mA  IQ   R   0x7H7HQ^ey  BJ   K   3(:K:KTah|  }     .   ,83D3D\`p  q   /md6l6RUc6cfjkufv6vy|6|  FS)  +  + +4 + H  + +,E  M  HU  \t +  u  + +D'	  QS  \i +  j   u  %   ():):<V\  ]   +H,=,=mZ`  a   .  0Q   R   '(xy}  G  zH  )H  In  )n  v~  vH  vH   I  + +Jx  Of +  g   -d  4^DG/IQ]  _   ,T2JDG.IQ]  _   k5aDG1IOX  Z   n4  9IDG4IO[  ]   0t  =DDG8IOT  V o~  HN  GO  oP   1 >O EH9I Pa  b cl   .T ;DDG6IQ]dr  t
   0t =QDG8IO_  a
   :  GWDGBIOi  k   u  %  0
 ( '**	 11 k l 
 +     	0emp  q   o%) +a &b(+   -   t4f/g'3&   B   48r3s'47   D   x6HxO`O`  a   [  1 " #
 ""5/P 0_(0 # 2
 **8H*I$  
r *!,,W;\ :g2@8* - V  O]gkNl   e*@  A K   g/?#E$'  )   9  -  Nv V&11,E` ?F7JU]T^ 2 `  TblpSq  " "5/E " F P  " "<Km$' # )  " " " 7 %TZ [!,,W;V :V6E{T\6G6I2@	 - B 
 Xgpzo{W|   j/I  J T M  O]  O_ O^  hp  gq  OrNs t   l1p  q {   igG $A  B   h\  :   fJZ  H(EEG   " "#4  <G "  H  " "#=  Ef "  g   <#9#9  :  Nz Z"--h=`  oR  Yh  s~  @H  rI-  J    xo  >   4;S  T   y4'8AT  \]   ^   <eT`  hg   h   0$}[g  of   g   1;q  |H  OW   X   |U<  WX   Y   N  3 !^PU V
 ##F1N 0K(1 $ 3 ,,:J,K%   +#..w=_ <P4ChZ / Y  P^hlOm   u+A  B L   J  / !_QW X(33LGc Ap9MX`Wa 4 c  UcmqTr  # #E0F # G Q  # # # 9 &/V\ ]$//?^<\9A
5E 0 G  Zir|q}Y~   
1K  L V   \%=%=  > "oR\ ]&11	O	PS[	[	b	c
dfn
o	J	K
L IJ	 2   $ H/>>L\>] #-   5@@	9EFJ	! A    ' '
9b ' c  ' '
C  Gy '  z  ' 'U  Js  |H '  I  ' '  FG  P\ '  ]  ' 'S  Hl  sv '  w  ' '-@ ' A *>Vci j %%h5Y 3^+6 & 8 "00>N0O '   " -'227Ae @q8IT\S] 3 _  R`jnQo     -C   D N     2B&K'* ! ,     l   3 #7HU[ \,77Ki EQ=S^f]g 8 i  WeosVt  % %e2H % I S  % %lKNk,/ & 1  % %+< % = (<MZ` a'227Aa @O<G;R8I 3 K  [js}r~Z     2L   M W     /^   _     l&?&?   @ #7HU_ `(33HCh  w\  cu  @K  MU  V3  W   ! !( ! A  ! !"7>V ! W  ! !"GQU^k  sO  V} !  ~  ! !"CTZg  oG  N| !  }  ! !$I\y ! z  ! !'8 ! 9 $8IV[ \
 %%h5W3 ,7 & 8 "00>N0O $   " -%006W=^:Ex9P6E	 1 G 
   xo  >   x.C  D   9  AE  Ol   m   ;  CV  ah  jr  `s   t   |2N  O   GRXZaQb  jY   Z)FFPUFV   " "#7  UP "  Q  " "#8  UQ "  R   ;U  RM   N   J  / !5FSX Y +55jGkBp?JH>U;O 6 Q  ^m  wA  vB  ^C  # #J5O # P Z3PPR   ' '	8H ' I  ' ';U^j ' k  # #K6H # I  # #O:P # Q%;%X%X%Z " " / /0AHp / q " / /0DK}  GS /  T  # #)E)E # F &:KXb c'227Ap?n<K[Zb<M<O8I	 3 K 
 [js}r~Z     2L   M W     /^   _ zH  JX  JZ JY  ck  bl  JmIn zo     6k   l v     Kw 'V ! W      '\(4 ! 6 -IIK   # #H< # @  # #K6LUa # b.KKM   % %&7  ?J %  K  % %&@  Hi %  j     l&?&?   @ #7HU_ `(33HCn  }h  oA  LW  Ya  Kb3  c   ! !( ! A  ! !"7>V ! W  ! !)gx5H  PD !  E  ! !"?&RYIZ  b !  @  ! !.67:K  Sa !  b  ! !"4>t  || !  }  ! !'8 ! 9 $8IV[ \)44Y:rACJ]>I8=T 5 V   " "<6R " S  " "82D " E  " ";5F " G  " "?9N " O  " "=67:K(Q # S  " ">FG;L(R # T  " "#:VWDU([ # ]  " "#@6SZJ[(n # p  " "?VH(N # P  " "#AFT[K\(t # v  " "#<vwFW(r # t  " ";5gnq " r  " "#B)X,2G+< # >  " "#J  RP  WZ "  [1NNP   & &'>  Ft  {~  FI &  J  & &'D  LX  am &  n$9$V$V$X ! ! . ./N  Vu  |L .  M ! . ./T  \{  DP .  Q  " " " 7 %9JWa b &&y7G 4a  dh  iw  dx  4x  {_  4_  fr08z ' ; $00=[0\ ->       ) 6 2
 ((;M5PWe2: ) =  (44UAa4b !/$!?     9  -  V 4
 ""5/P[`04  6k  nr  sA  nB  6B  EM  6M  PT  Un  Po  6o  rk  6k  1l  ou  1u  x|  }S  VZ  [p  Vq  }q  tI  }I  xJ  1J  MS  1S  VZ  [b  ei  jG	  eH	  [H	  K	Z
  [Z
  V[
  1[
(03;3P3P,;[(T^,=}h,X	 # Y
 #//59  ;U  hk  6l692 0 G  #1.2B2A8U_J`mv2w2y #z     n! #N 47	8
  (c  3   h-NVW`g  h 
  	  .P  cf  )g   h 
  	;W!"k  B  C  D 
  V(Y]  _U  hk  Zl   m 
  )!  #[  nq  r+  -   Y! #c368  9   /9O! #=368  ' "  $   8BX! #c368  ' "  $   t,bux'y  z 
  7!  #W  jm  n+  -    9! #i368  9
   .|! #@368  9   gI<Ybo  p 
  'T]i  j 
  	(hq}  ~ 
  hc9! #M 478  9
   ! #A368  ,	  -
   0B!"r368  9   X  @Y!"o368  9 668   *!"C368+  -   0*K`! #8 47	8
  (  )   .! #]368  (	  )
   K! #8 478  9
 8	 
  *'B$(  *E  *L  *L  PY  *L  *Z:=%?&.	  0
   !"U368+1  6   
 /s @C*D MY  Z   T 3w?B.DMY`e  g   hS$T  K\  or  Fs   t 
  3$  @J  ]`  ;a   b 
  2  ?H  [^  :_   ` 
  0tZ^  ``  sv  [w   x::<    6|#' )V :=	$>  ?   =G[#' )9
 :=$>  ?   S%eT-1Z^  ` 
v .
 $$W3X_i1i.6-E % G   '(@  A   $ 7>`"H  6$AAC   " "82OXd " e  " "7Cic(,  .Y  lo  )p # q   $
8 F@  A   ./R[g  h   ./R[g  h   /0^gs  t   +2QZg+  -   +,JS_  `   /0R[h)  +   $	0R[g  h   $
1o  p   +}]QWn  p   +D  2C  VY  -Z"HR`  b3 3j   *3DA  UE   F   u  %  0
 )),=k/k(7,4: * 7    07e%-%7%7  9   z  1`  iu   v   J  / !f 5
 ""5/Q0r )1,4: # 7
   'B  C 
  
)[ckcucu  v 
  0Bm  o ==?      !7  ?H  Q]  gl    m     xsT]! #M368 ! 9   2=xO`O`gv  w 
  S  ! 
v .
 ((;W5].<2: ) =    g,RZ]  ^   9  -*
;  %    ' ')D)DR)H)M)MzOjOjkmOnOsOs(t u & & ! ( (**E*Eb*I*N*NPZPkPklnPoPtPt)u v
 ((;M5d.<2: ) =  #//
AU_hps/t+YUYZ    dG)B_hu  v   dI4`iu  v   9  -  T 2
 ""5/T 0E(0 # 2
 **8H*I   
v . ++F9Tb}  IT  V^  H_  fs+  t+>>~N   & &t\Dz & Z  & &y4o & V  & &y| & D  & &z & F  & &xk & B  & &'9  AZ &  [  & &~L & I  & &'7>q & r*==m  NV  W   % %gO % D  % %i'89LV^g}  EP %  Q  % %ouMc  kK %  L  % %&CU[q  yr %  s  % %&7Ndkw  p %  q  % %&8Bx  CO  Xn  u %  @  % %lEJ`  hc %  d   (  + >%'  **57T 8U4?3J0< + >   F)Fc  R   J  =w   x   6  Ov  @]   ^   8'  QU  `g  iq  _r   s     ) .U S#..y?U;Q8CX7N4D / F    -Fc  R   
1U  V   j7i'3   5     3g   h   .MW\'3   5    9@}  HM'3   5    ?  Gf  m}   ~    9@P  XD   E    >EU  ]S   T    9  WC   D    3:h  i   	0T  U   [  1 "nQU V"--h=R:O7MOs7BH7N>F>[>[3B . D   ,,X<r,s   y/_ht  u'
;    J  / !^PT U$//
AX<S9OQu9Dh9P@H@]@]5F 0 H      1A   B     3E   F     7M   N     !29a   b!..xd  DN  ad  ?e.  f'=      l&?&?   @ #~R\ ]
  **=?]7_fv4<: + ?  jyiz   -[  \ f   [  1 "z :
  **=?]7_fv4<g3F + H  ap`q   -R  S ]   	0JRU  V   &6=u  v   [  1 "z :
 #--.>Ef:\cv7?6I . K  dsct  " "60U " V `  " "<(I9N(P # R  " " " 7 %* =
 ((;W 6C.<2:G1D ) F  _n^o   f+P  Q [   gS&~  V   9  -  Z 8
 !++NAb 9K1B5=w4G , I  bqar     .S   T ^     VJ[   \     l   3 #
 ;
 ""5/Y`h 0v,4gw+G # I
 p  pA
  %a  b l 
  c5}  M 
  X  & 
z 2
 $$W3_fp 2z.6-I % K rA  rC  &'c  d n   &UAQ  R   {  +  4
 %%h+L 3}+6/7.A	 & C
 ((6`(a'TB    6
  3     ' * 5
 #--.>E} ;O  Vi7?'6R . T  {J  {L  " "60l " m w  " "<sDX(` # b  " " " 7 %* =
 %//0B  JD =S5J9A7G8T 0 V  &226@|2}')   $ $\n[t $ u  $ $*: $ ; 'J ?
 $$W3I1`*4.6-@ % B ap`q  &'Gs  S ]   ()JS_  `   u  % )= >
 ##F1g 1v)2-5J $ 8 &&v4qy|&}')    -r  |H   I   d  # (D E
 ""5/r 0M(0,4: # 7
 Ve  ni  Vj
  %G  H R 
  j  0e   f 
  c  9~    
  +U  B  HT  [l   m 
  U  :E  NZ   [ 
  
)ir~   
  *  2K  T`   a 
  m2Ybn  o 
  S  ! 
v .
 ##F1f0f4<4Q4Q)2 $ 4 ,,:J,K$   +"--
	#	$ r s(Ix8	 .     h->  ?TabpTq   l1F  G Q   /#J$%%6  8   dG2S\h  i   o4|  FR   S   m2NWc  d   m2`  a   k0L  M   m2H  I   /  7o   p   0  8~      m  2\   ]   n  4g   h   9  -  OPV W-88	/	0 r s(Ix8	" 9    ( (8N ( Odq  sA  eB  ( (<V ( W a  ( ():#V$%%6 ) 8  ( (w=clx ( y  ( (  @R  [g (  h  ( (=p ( q  ( (;\ ( ]  ( (=X ( Y  ( ():  BI (  J  ( ();  CS (  T  ( (  =t (  u  ( (  ?@ (  A  ( (.C ( D +[a b"--
	0	1 W X!;,	S[-/11	 . 
  . /   ?e  D,i@    OPV W&11	4	5 [ \!;,	S[-/11	 2 
  2 3  ! !* ! M!0)!D   $TZ [(33	J	K p q!;,	S[-/11	 4 
  4 5  # #D # I#2I#F    &/V\ ]"--
	8	9 J K (L)XGgh	 .     ikCw	4     i1U\q  r   n6U_h  pU   V   h-|  }   mVBb  mH   I   h-F  G   h-V  W   .  GB  KW   X   k0A0A  BN]goNp   jx/@/@  A KDS]eDf   h-e&6  88A   m)Bbkx  y   /  7z   {   0  8D   E   m  2f   g   n  4r   s   j/[  \   9  -  OPd e&11	o	 ! "(Ix9Y[gh	 2    ! !(1F ! G  ! !)5c'N " P  ! !*'n)5 " 7  ! !"3 (m " n  ! !"4 (v " w  ! !*3_ ! `  ! !"@6SZJ[ )L " M  ! !} ! 5 $TZ [!,,		4	5	@	H	I
JLT
U	Q	R
SU]
^ 
I	J
K NT
T 
E	F	
G
 ;<	 - 	 ? C%44BR4S (  -88	,`a(Ix8	 9    $ $XH $ =  $ $Y(8K  Sg $  h  $ $*: $ ; ';N[` a.99	4 Q R (Ix9Y[gh	 :    % %hX % >  % %h5K % L  % %gS  @I %  J3PPR   % %oHKir~  IM %  N  % %&6XLk  uB  LP %  Q  % %&7  ?D %  E  % %&8  @N %  O  % %j7c % d  % %+< % = (<O\k l*55
	0 Q R (Ix8	 6    ! !( ! :  ! !(1C ! DXeftXu  ! !,5J ! K U  ! !"3'N()): " <
  ! !$6W`l ! m  ! !/8u  K !  L  ! !-6R[g ! h  ! !+4P ! Q  ! !-6L ! M  ! !"3  ;x !  y  ! !"4  <B !  C  ! !- 7e ! f  ! !. 8g ! h  ! !} ! 5 $8KXg h"--
	k	D(Ix8	 .     i'81Dt  [R   S,<,Y,Y,[ ) ) 6 67S\h  pR 6  S ) 6 67V]w  AN  U{ 6  |   9t  L  OPU V 2 1''
9a4\8@8U8U-: ( <   _3O  ZH   I CR  \b  [c  Cd  /6]giqt  u    Y-LUakp  q   X,Wag  hhw  BH  AI  iJ  \0Z  [ e   [/]gk  l   T93OXely  z   [/\fj  k   .5\ft  u   29bkw  x!2!2!2<Rc!d    "@  A FU C . . ++NAt8k<D<Y<Y1B , D  L[  ek  dl  Lm     5Wacksk}k}   ~  I     0_io   p     3eos   t     y7S\ip}   ~     !29dn|   }     i   0 # G
 ""5/C3;3P3P/3  5I  0J M 0 )1,4:# # 7
$   
  /Q  dg  *h   i 
  t,q  EH  (I   J 
  CD|  } 
  	-_ru(v  w 
  S  ! 
   *445L  TW 4J,F  5  H   ) )$	  Ff  y|  A}  FN )  OP_iqPr  ) )(  :H&6 * DDM  ) )$0AH`jt ) u  ) )/D ) E , -
 &&y7\ 0C(4 ' 6 sB  LQ  Sc  Kd  se   L!d  ffo   N!X#0~  G     )   && 
L F4)*D1L,MtTaObc* //)7 ' :   D)2T#/  1   	^qt	uw{	{  ~B  C  QT  ~U  
U$),	  @
   y	,	D  (   N  FT  gj  Ak  tA   B
 (7'8   
	Zlo	pc   %&99  Wd9  e      D 4 0 (( 
O F4'($/J*KTR_M`a	( 11I	5 )  8   hT2p  DG  .H  KO  .O  QU  V~  QT  dh  Qi  .i  lp  .p &D Q.R[|  GQ  R   dI4V_k  l   y	,	D  (   n9$  HX  kn  Co  xE   F
 (7'8   
	Zmp	qc   %  # #(  Ai #  j   7  F  T 2
 $../@  Hy 0t(< / >   # #F  2 #  @  # #F,GP\fk  sh #  i  # #JS  @h
 #  i
  # #O#  Eo	 #  p	  # #GL%  Ws #  t  # #I}Cs\_  gm #  n  # #D*  <X #  Y  # #_\SX  `f #  g  # #%6|UZ  bL #  M  # #L  8k #  l  # # # 9 & '
 ",, 
c j		 -   0>>! ?    '   $ %
 !9 C C 
k r !D !   * *
	 
Z +   * * 
t +  9UU_cUd   % %	e &   % %	

 
e &   % %	

 
L &   % %	

 
H	 &  &C%_%_in%_%o " " / / 
l 0 m # / / 
h 0   * *			 + 
  * * 
S + 
  * **	 S	 +   * *0F * G - .
  8BB 
j q  C     ) )
	 
Z *  8TT^bTc   % %	e &   % %	k &   % %	

 
X &   % %	0 &   ) ) 
T *   ) )	 
F	 *   ) ) 
t *   ) )			 *   ) ) 
S * 
  ) )*	 
Q	 *   ) )/D ) E , -
 #;"E"E 
] d #F #    , ,

	 
S	 -    , ,	i -    , , 
o -    , ,	0 -    , ,	 
 -    , ,	 
V	 -    , ,	 
T	 -    , ,	n -    , , 
q -    , ,
 
c	 -    , ,	 
n	 -    , ,	1 
s	 -    , ,	 
D	 -    , ,2J , K / 0
 ",,_  Dt 0`(:,7=,1	 - 3   ! !&#  En !  o  ! !(T  KT !  U2OOY]O^   ( (c  I^ (  _  ( ()<3  Nt (  u  ! !$x6U^d ! e  ! !} ! 5 $ % \tuPXX(9((CF(KKuv##F1d04  6~  1  BX  1X  [h  1h k 1 	  I  ]a  	b	1be	
1 22 $ D   .T  ;i  |  6@  HK  UY   Z   D1s  GJ  -K  SV  `d   e   j  ) !
6 $
: ! _Hh'..
8S8STV8W8\8\/]^_ %    % % 'B zF kU!  	$  	O	
  i77d?V]`]g]ghixR vst   %FR! ,FR/ AFS $FR7 (FS MFS?R!FR,R/FR4R7FSR<FSS FS SFSSFS S*FS<S;FS<