Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tapisv3 #1

Merged
merged 21 commits into from
Nov 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dapi credentials store instructions in README
kks32 committed Sep 30, 2024
commit 1834ed2a864005f97bf6b46677a4f5aa4883dd04
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,15 @@ pip install git+https://github.com/DesignSafe-CI/dapi.git --quiet

## Example usage:

### Storing credentials

Dapi uses the Tapis v3 SDK to authenticate with the DesignSafe API. To store your credentials, create a `.env` file in the root of your project with the following content:

```shell
DESIGNSAFE_USERNAME=<your_designsafe_username>
DESIGNSAFE_PASSWORD=<your_designsafe_password>
```

### Jobs

* [Jupyter Notebook Templates](example-notebooks/template-mpm-run.ipynb) using dapi.
@@ -66,7 +75,7 @@ Install the latest version of `dapi` and restart the kernel (Kernel >> Restart K
```python
# Remove any previous installations
!pip uninstall dapi -y
# Install
# Install
!pip install dapi --quiet
```

4 changes: 2 additions & 2 deletions dapi/auth/auth.py
Original file line number Diff line number Diff line change
@@ -19,8 +19,8 @@ def init():
load_dotenv()

# Try to get credentials from environment variables
username = os.getenv("DS_USER_NAME")
password = os.getenv("DS_PASSWORD")
username = os.getenv("DESIGNSAFE_USERNAME")
password = os.getenv("DESIGNSAFE_PASSWORD")

# If environment variables are not set, prompt user for input
if not username:
8 changes: 4 additions & 4 deletions tests/auth/test_auth.py
Original file line number Diff line number Diff line change
@@ -9,8 +9,8 @@ class TestAuthInit(unittest.TestCase):
def test_init_with_env_variables(self, mock_environ, mock_tapis):
# Setup
mock_environ.get.side_effect = {
"DS_USER_NAME": "test_user",
"DS_PASSWORD": "test_password",
"DESIGNSAFE_USERNAME": "test_user",
"DESIGNSAFE_PASSWORD": "test_password",
}.get
mock_tapis_obj = MagicMock()
mock_tapis.return_value = mock_tapis_obj
@@ -58,8 +58,8 @@ def test_init_with_user_input(
def test_init_authentication_failure(self, mock_environ, mock_tapis):
# Setup
mock_environ.get.side_effect = {
"DS_USER_NAME": "invalid_user",
"DS_PASSWORD": "invalid_password",
"DESIGNSAFE_USERNAME": "invalid_user",
"DESIGNSAFE_PASSWORD": "invalid_password",
}.get
mock_tapis_obj = MagicMock()
mock_tapis.return_value = mock_tapis_obj