Skip to content

Commit

Permalink
Set numpy and pandas to be compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
kks32 committed Oct 1, 2024
1 parent 72d3fd5 commit 992ea3e
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 151 deletions.
6 changes: 6 additions & 0 deletions dapi/auth/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ def init():
Tries to read credentials from environment variables first.
If not found, prompts the user for input.
Save the user credentials in the .env file.
```
DESIGNSAFE_USERNAME=<username>
DESIGNSAFE_PASSWORD=<password>
```
Returns:
object: The authenticated Tapis object.
"""
Expand Down
110 changes: 64 additions & 46 deletions docs/dapi/auth/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,36 @@ <h1 class="modulename">
</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a><span class="sd"> Tries to read credentials from environment variables first.</span>
</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a><span class="sd"> If not found, prompts the user for input.</span>
</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a>
</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="sd"> Returns:</span>
</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a><span class="sd"> object: The authenticated Tapis object.</span>
</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="s2">&quot;https://designsafe.tapis.io&quot;</span>
</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a>
</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a> <span class="c1"># Load environment variables from .env file</span>
</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a> <span class="n">load_dotenv</span><span class="p">()</span>
</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a>
</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a> <span class="c1"># Try to get credentials from environment variables</span>
</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a> <span class="n">username</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_USERNAME&quot;</span><span class="p">)</span>
</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_PASSWORD&quot;</span><span class="p">)</span>
</span><span id="L-24"><a href="#L-24"><span class="linenos">24</span></a>
</span><span id="L-25"><a href="#L-25"><span class="linenos">25</span></a> <span class="c1"># If environment variables are not set, prompt user for input</span>
</span><span id="L-26"><a href="#L-26"><span class="linenos">26</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">username</span><span class="p">:</span>
</span><span id="L-27"><a href="#L-27"><span class="linenos">27</span></a> <span class="n">username</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;Enter username: &quot;</span><span class="p">)</span>
</span><span id="L-28"><a href="#L-28"><span class="linenos">28</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">password</span><span class="p">:</span>
</span><span id="L-29"><a href="#L-29"><span class="linenos">29</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="p">(</span><span class="s2">&quot;Enter password: &quot;</span><span class="p">)</span>
</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="sd"> Save the user credentials in the .env file.</span>
</span><span id="L-14"><a href="#L-14"><span class="linenos">14</span></a><span class="sd"> ```</span>
</span><span id="L-15"><a href="#L-15"><span class="linenos">15</span></a><span class="sd"> DESIGNSAFE_USERNAME=&lt;username&gt;</span>
</span><span id="L-16"><a href="#L-16"><span class="linenos">16</span></a><span class="sd"> DESIGNSAFE_PASSWORD=&lt;password&gt;</span>
</span><span id="L-17"><a href="#L-17"><span class="linenos">17</span></a><span class="sd"> ```</span>
</span><span id="L-18"><a href="#L-18"><span class="linenos">18</span></a>
</span><span id="L-19"><a href="#L-19"><span class="linenos">19</span></a><span class="sd"> Returns:</span>
</span><span id="L-20"><a href="#L-20"><span class="linenos">20</span></a><span class="sd"> object: The authenticated Tapis object.</span>
</span><span id="L-21"><a href="#L-21"><span class="linenos">21</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="L-22"><a href="#L-22"><span class="linenos">22</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="s2">&quot;https://designsafe.tapis.io&quot;</span>
</span><span id="L-23"><a href="#L-23"><span class="linenos">23</span></a>
</span><span id="L-24"><a href="#L-24"><span class="linenos">24</span></a> <span class="c1"># Load environment variables from .env file</span>
</span><span id="L-25"><a href="#L-25"><span class="linenos">25</span></a> <span class="n">load_dotenv</span><span class="p">()</span>
</span><span id="L-26"><a href="#L-26"><span class="linenos">26</span></a>
</span><span id="L-27"><a href="#L-27"><span class="linenos">27</span></a> <span class="c1"># Try to get credentials from environment variables</span>
</span><span id="L-28"><a href="#L-28"><span class="linenos">28</span></a> <span class="n">username</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_USERNAME&quot;</span><span class="p">)</span>
</span><span id="L-29"><a href="#L-29"><span class="linenos">29</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_PASSWORD&quot;</span><span class="p">)</span>
</span><span id="L-30"><a href="#L-30"><span class="linenos">30</span></a>
</span><span id="L-31"><a href="#L-31"><span class="linenos">31</span></a> <span class="c1"># Initialize Tapis object</span>
</span><span id="L-32"><a href="#L-32"><span class="linenos">32</span></a> <span class="n">t</span> <span class="o">=</span> <span class="n">Tapis</span><span class="p">(</span><span class="n">base_url</span><span class="o">=</span><span class="n">base_url</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="n">password</span><span class="p">)</span>
</span><span id="L-33"><a href="#L-33"><span class="linenos">33</span></a>
</span><span id="L-34"><a href="#L-34"><span class="linenos">34</span></a> <span class="n">t</span><span class="o">.</span><span class="n">get_tokens</span><span class="p">()</span>
</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a>
</span><span id="L-36"><a href="#L-36"><span class="linenos">36</span></a> <span class="k">return</span> <span class="n">t</span>
</span><span id="L-31"><a href="#L-31"><span class="linenos">31</span></a> <span class="c1"># If environment variables are not set, prompt user for input</span>
</span><span id="L-32"><a href="#L-32"><span class="linenos">32</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">username</span><span class="p">:</span>
</span><span id="L-33"><a href="#L-33"><span class="linenos">33</span></a> <span class="n">username</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;Enter username: &quot;</span><span class="p">)</span>
</span><span id="L-34"><a href="#L-34"><span class="linenos">34</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">password</span><span class="p">:</span>
</span><span id="L-35"><a href="#L-35"><span class="linenos">35</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="p">(</span><span class="s2">&quot;Enter password: &quot;</span><span class="p">)</span>
</span><span id="L-36"><a href="#L-36"><span class="linenos">36</span></a>
</span><span id="L-37"><a href="#L-37"><span class="linenos">37</span></a> <span class="c1"># Initialize Tapis object</span>
</span><span id="L-38"><a href="#L-38"><span class="linenos">38</span></a> <span class="n">t</span> <span class="o">=</span> <span class="n">Tapis</span><span class="p">(</span><span class="n">base_url</span><span class="o">=</span><span class="n">base_url</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="n">password</span><span class="p">)</span>
</span><span id="L-39"><a href="#L-39"><span class="linenos">39</span></a>
</span><span id="L-40"><a href="#L-40"><span class="linenos">40</span></a> <span class="n">t</span><span class="o">.</span><span class="n">get_tokens</span><span class="p">()</span>
</span><span id="L-41"><a href="#L-41"><span class="linenos">41</span></a>
</span><span id="L-42"><a href="#L-42"><span class="linenos">42</span></a> <span class="k">return</span> <span class="n">t</span>
</span></pre></div>


Expand All @@ -111,37 +117,49 @@ <h1 class="modulename">
</span><span id="init-11"><a href="#init-11"><span class="linenos">11</span></a><span class="sd"> Tries to read credentials from environment variables first.</span>
</span><span id="init-12"><a href="#init-12"><span class="linenos">12</span></a><span class="sd"> If not found, prompts the user for input.</span>
</span><span id="init-13"><a href="#init-13"><span class="linenos">13</span></a>
</span><span id="init-14"><a href="#init-14"><span class="linenos">14</span></a><span class="sd"> Returns:</span>
</span><span id="init-15"><a href="#init-15"><span class="linenos">15</span></a><span class="sd"> object: The authenticated Tapis object.</span>
</span><span id="init-16"><a href="#init-16"><span class="linenos">16</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="init-17"><a href="#init-17"><span class="linenos">17</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="s2">&quot;https://designsafe.tapis.io&quot;</span>
</span><span id="init-18"><a href="#init-18"><span class="linenos">18</span></a>
</span><span id="init-19"><a href="#init-19"><span class="linenos">19</span></a> <span class="c1"># Load environment variables from .env file</span>
</span><span id="init-20"><a href="#init-20"><span class="linenos">20</span></a> <span class="n">load_dotenv</span><span class="p">()</span>
</span><span id="init-21"><a href="#init-21"><span class="linenos">21</span></a>
</span><span id="init-22"><a href="#init-22"><span class="linenos">22</span></a> <span class="c1"># Try to get credentials from environment variables</span>
</span><span id="init-23"><a href="#init-23"><span class="linenos">23</span></a> <span class="n">username</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_USERNAME&quot;</span><span class="p">)</span>
</span><span id="init-24"><a href="#init-24"><span class="linenos">24</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_PASSWORD&quot;</span><span class="p">)</span>
</span><span id="init-25"><a href="#init-25"><span class="linenos">25</span></a>
</span><span id="init-26"><a href="#init-26"><span class="linenos">26</span></a> <span class="c1"># If environment variables are not set, prompt user for input</span>
</span><span id="init-27"><a href="#init-27"><span class="linenos">27</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">username</span><span class="p">:</span>
</span><span id="init-28"><a href="#init-28"><span class="linenos">28</span></a> <span class="n">username</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;Enter username: &quot;</span><span class="p">)</span>
</span><span id="init-29"><a href="#init-29"><span class="linenos">29</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">password</span><span class="p">:</span>
</span><span id="init-30"><a href="#init-30"><span class="linenos">30</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="p">(</span><span class="s2">&quot;Enter password: &quot;</span><span class="p">)</span>
</span><span id="init-14"><a href="#init-14"><span class="linenos">14</span></a><span class="sd"> Save the user credentials in the .env file.</span>
</span><span id="init-15"><a href="#init-15"><span class="linenos">15</span></a><span class="sd"> ```</span>
</span><span id="init-16"><a href="#init-16"><span class="linenos">16</span></a><span class="sd"> DESIGNSAFE_USERNAME=&lt;username&gt;</span>
</span><span id="init-17"><a href="#init-17"><span class="linenos">17</span></a><span class="sd"> DESIGNSAFE_PASSWORD=&lt;password&gt;</span>
</span><span id="init-18"><a href="#init-18"><span class="linenos">18</span></a><span class="sd"> ```</span>
</span><span id="init-19"><a href="#init-19"><span class="linenos">19</span></a>
</span><span id="init-20"><a href="#init-20"><span class="linenos">20</span></a><span class="sd"> Returns:</span>
</span><span id="init-21"><a href="#init-21"><span class="linenos">21</span></a><span class="sd"> object: The authenticated Tapis object.</span>
</span><span id="init-22"><a href="#init-22"><span class="linenos">22</span></a><span class="sd"> &quot;&quot;&quot;</span>
</span><span id="init-23"><a href="#init-23"><span class="linenos">23</span></a> <span class="n">base_url</span> <span class="o">=</span> <span class="s2">&quot;https://designsafe.tapis.io&quot;</span>
</span><span id="init-24"><a href="#init-24"><span class="linenos">24</span></a>
</span><span id="init-25"><a href="#init-25"><span class="linenos">25</span></a> <span class="c1"># Load environment variables from .env file</span>
</span><span id="init-26"><a href="#init-26"><span class="linenos">26</span></a> <span class="n">load_dotenv</span><span class="p">()</span>
</span><span id="init-27"><a href="#init-27"><span class="linenos">27</span></a>
</span><span id="init-28"><a href="#init-28"><span class="linenos">28</span></a> <span class="c1"># Try to get credentials from environment variables</span>
</span><span id="init-29"><a href="#init-29"><span class="linenos">29</span></a> <span class="n">username</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_USERNAME&quot;</span><span class="p">)</span>
</span><span id="init-30"><a href="#init-30"><span class="linenos">30</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s2">&quot;DESIGNSAFE_PASSWORD&quot;</span><span class="p">)</span>
</span><span id="init-31"><a href="#init-31"><span class="linenos">31</span></a>
</span><span id="init-32"><a href="#init-32"><span class="linenos">32</span></a> <span class="c1"># Initialize Tapis object</span>
</span><span id="init-33"><a href="#init-33"><span class="linenos">33</span></a> <span class="n">t</span> <span class="o">=</span> <span class="n">Tapis</span><span class="p">(</span><span class="n">base_url</span><span class="o">=</span><span class="n">base_url</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="n">password</span><span class="p">)</span>
</span><span id="init-34"><a href="#init-34"><span class="linenos">34</span></a>
</span><span id="init-35"><a href="#init-35"><span class="linenos">35</span></a> <span class="n">t</span><span class="o">.</span><span class="n">get_tokens</span><span class="p">()</span>
</span><span id="init-36"><a href="#init-36"><span class="linenos">36</span></a>
</span><span id="init-37"><a href="#init-37"><span class="linenos">37</span></a> <span class="k">return</span> <span class="n">t</span>
</span><span id="init-32"><a href="#init-32"><span class="linenos">32</span></a> <span class="c1"># If environment variables are not set, prompt user for input</span>
</span><span id="init-33"><a href="#init-33"><span class="linenos">33</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">username</span><span class="p">:</span>
</span><span id="init-34"><a href="#init-34"><span class="linenos">34</span></a> <span class="n">username</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s2">&quot;Enter username: &quot;</span><span class="p">)</span>
</span><span id="init-35"><a href="#init-35"><span class="linenos">35</span></a> <span class="k">if</span> <span class="ow">not</span> <span class="n">password</span><span class="p">:</span>
</span><span id="init-36"><a href="#init-36"><span class="linenos">36</span></a> <span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="p">(</span><span class="s2">&quot;Enter password: &quot;</span><span class="p">)</span>
</span><span id="init-37"><a href="#init-37"><span class="linenos">37</span></a>
</span><span id="init-38"><a href="#init-38"><span class="linenos">38</span></a> <span class="c1"># Initialize Tapis object</span>
</span><span id="init-39"><a href="#init-39"><span class="linenos">39</span></a> <span class="n">t</span> <span class="o">=</span> <span class="n">Tapis</span><span class="p">(</span><span class="n">base_url</span><span class="o">=</span><span class="n">base_url</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="o">=</span><span class="n">password</span><span class="p">)</span>
</span><span id="init-40"><a href="#init-40"><span class="linenos">40</span></a>
</span><span id="init-41"><a href="#init-41"><span class="linenos">41</span></a> <span class="n">t</span><span class="o">.</span><span class="n">get_tokens</span><span class="p">()</span>
</span><span id="init-42"><a href="#init-42"><span class="linenos">42</span></a>
</span><span id="init-43"><a href="#init-43"><span class="linenos">43</span></a> <span class="k">return</span> <span class="n">t</span>
</span></pre></div>


<div class="docstring"><p>Initialize a Tapis object with authentication.
Tries to read credentials from environment variables first.
If not found, prompts the user for input.</p>

<p>Save the user credentials in the .env file.</p>

<pre><code>DESIGNSAFE_USERNAME=&lt;username&gt;
DESIGNSAFE_PASSWORD=&lt;password&gt;
</code></pre>

<p>Returns:
object: The authenticated Tapis object.</p>
</div>
Expand Down
Loading

0 comments on commit 992ea3e

Please sign in to comment.