Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This will install `trakka` to `~/.local/bin`. You can pass a custom directory li
The CLI requires Python to run. If you would like to use conda to install Python, install the CLI, and save the necessary environment variables,
you can first install either Miniforge (https://github.com/conda-forge/miniforge) or Miniconda (https://docs.conda.io/en/latest/miniconda.html). We recommend Miniforge for most users.

Note that as a part of installing the CLI, you will need to set the environment's `AT_URI` variable.
Note that as a part of installing the CLI, you will need to set the environment's `TRAKKA_URI` variable.

### Install into a conda environment (optional but recommended)

Expand All @@ -44,9 +44,9 @@ variables set and the `at-login` alias, run:
conda create -n trakka python=3.12
conda activate trakka
python -m pip install trakka
conda env config vars set AT_URI=[VALUE]
conda env config vars set TRAKKA_URI=[VALUE]
mkdir -p ${CONDA_PREFIX}/etc/conda/activate.d
echo "alias at-login=\"export AT_TOKEN=\\\$(trakka auth user)\"" > ${CONDA_PREFIX}/etc/conda/activate.d/trakka-alias.sh
echo "alias at-login=\"export TRAKKA_TOKEN=\\\$(trakka auth user)\"" > ${CONDA_PREFIX}/etc/conda/activate.d/trakka-alias.sh
```
Note that the last two lines are valid only for Linux/Mac and will not work on Windows. These lines create an alias `at-login`
in the conda environment, which will log you in to the CLI.
Expand All @@ -67,36 +67,36 @@ To install without conda, simply install with
python -m pip install trakka
```

You will need to set the environment variable `AT_URI`.
You will need to set the environment variable `TRAKKA_URI`.
You can do this by running:

> #### Mac / Linux
>```
>export AT_URI=[VALUE]
>export TRAKKA_URI=[VALUE]
>```
>You may wish to add this to your `.bashrc` or `.zshrc` file.

>#### Windows: Powershell
>```
>$Env:AT_URI = [VALUE]
>$Env:TRAKKA_URI = [VALUE]
>```

To use the CLI, you must log in by setting the `AT_TOKEN` environment variable using the
To use the CLI, you must log in by setting the `TRAKKA_TOKEN` environment variable using the
`trakka auth user` command (see User Authentication, below).

> #### Mac / Linux
>You may wish to configure
>a login command for convenience:
>```
>alias at-login="export AT_TOKEN=\$(trakka auth user)"
>alias at-login="export TRAKKA_TOKEN=\$(trakka auth user)"
>```
>You may wish to add this to your `.bashrc` or `.zshrc` file.

> #### Windows: Powershell
>You may wish to configure
>a login command for convenience:
>```
>Function at-login { $Env:AT_TOKEN = trakka auth user }
>Function at-login { $Env:TRAKKA_TOKEN = trakka auth user }
>```
>You may wish to add this to your `config.ps1` file.

Expand Down Expand Up @@ -131,26 +131,26 @@ to the Trakka web interface, and will authenticate you via your institution's id
>at-login
>```
>
>Otherwise, you will need to set the `AT_TOKEN` environment variable. In a Mac or Linux environment you can run:
>Otherwise, you will need to set the `TRAKKA_TOKEN` environment variable. In a Mac or Linux environment you can run:
>```
>export AT_TOKEN=$(trakka auth user)
>export TRAKKA_TOKEN=$(trakka auth user)
>```

>#### Windows: Powershell
>
>```
>$Env:AT_TOKEN = trakka auth user
>$Env:TRAKKA_TOKEN = trakka auth user
>```

>#### Windows: Cmd
>
>Set the `AT_TOKEN` environment variable by first running
>Set the `TRAKKA_TOKEN` environment variable by first running
>```
>trakka auth user
>```
>to obtain a token string, and then running
>```
>set AT_TOKEN=<output of previous command>
>set TRAKKA_TOKEN=<output of previous command>
>```
>:w
> to set the environment variable.
Expand All @@ -161,31 +161,31 @@ This authentication mode is intended for long-term automated processes. Most use

To authenticate a process, you'll need to set the following environment variables:
```bash
AT_AUTH_PROCESS_ID
AT_AUTH_PROCESS_SECRET
TRAKKA_AUTH_PROCESS_ID
TRAKKA_AUTH_PROCESS_SECRET
```
Values for `AT_AUTH_PROCESS_ID` and `AT_AUTH_PROCESS_SECRET` will be provided to you by the Trakka team. Note that the secret value is sensitive.
Values for `TRAKKA_AUTH_PROCESS_ID` and `TRAKKA_AUTH_PROCESS_SECRET` will be provided to you by the Trakka team. Note that the secret value is sensitive.

Once these variables are set, run the following to authorise:

>#### Mac/Linux
>```
>export AT_TOKEN=$(trakka auth process)
>export TRAKKA_TOKEN=$(trakka auth process)
>```

>#### Windows: Powershell
>```
>$Env:AT_TOKEN = trakka auth process
>$Env:TRAKKA_TOKEN = trakka auth process
>```

>#### Windows: Cmd
>Set the `AT_TOKEN` environment variable by first running
>Set the `TRAKKA_TOKEN` environment variable by first running
>```
>trakka auth process
>```
>to obtain a token string, and then running
>```
>set AT_TOKEN=<output of previous command>
>set TRAKKA_TOKEN=<output of previous command>
>```
>to set the environment variable.

Expand Down Expand Up @@ -214,17 +214,17 @@ to see the usage of the `metadata add` command to upload metadata files.

| Name | Description |
|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| `AT_TOKEN` | Trakka auth token |
| `AT_URI` | URI for API endpoint |
| `AT_LOG_LEVEL` | Level of logging |
| `AT_LOG` | Set to `file` to redirecting logging to a temp file |
| `AT_CMD_SET` | Set to `trakka-admin` to display admin commands (these will not actually run successfully unless you have an appropriate role on the server) |
| `AT_TIMEZONE` | Set to change the default timezone used for datetime display and parsing. Default if unset is to use your local timezone. |
| `AT_SKIP_CERT_VERIFY` | Skips verification of the cert used by the Trakka backend |
| `AT_SKIP_VERSION_CHECK` | Skips checking of new CLI version |
| `AT_USE_HTTP2` | Uses HTTP2 (experimental) |

All commands require `AT_URI` and `AT_TOKEN` to be set, except for `auth` commands.
| `TRAKKA_TOKEN` | Trakka auth token |
| `TRAKKA_URI` | URI for API endpoint |
| `TRAKKA_LOG_LEVEL` | Level of logging |
| `TRAKKA_LOG` | Set to `file` to redirecting logging to a temp file |
| `TRAKKA_CMD_SET` | Set to `trakka-admin` to display admin commands (these will not actually run successfully unless you have an appropriate role on the server) |
| `TRAKKA_TIMEZONE` | Set to change the default timezone used for datetime display and parsing. Default if unset is to use your local timezone. |
| `TRAKKA_SKIP_CERT_VERIFY` | Skips verification of the cert used by the Trakka backend |
| `TRAKKA_SKIP_VERSION_CHECK` | Skips checking of new CLI version |
| `TRAKKA_USE_HTTP2` | Uses HTTP2 (experimental) |

All commands require `TRAKKA_URI` and `TRAKKA_TOKEN` to be set, except for `auth` commands.

## Project Structure

Expand Down
4 changes: 2 additions & 2 deletions test/end_to_end_tests/ete_cmd_bricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _create_field_if_not_exists(cli: TrakkaTestCli, field_name):
assert result.exit_code == 0, f'Failed to list fields as part of test setup: {result.output}'

# parse json array to find field_name matching "columnName" in the json
fields = json.loads(result.output)
fields = json.loads(result.stdout)
if field_name.casefold() not in [field['columnName'].casefold() for field in fields]:
result = cli.invoke([
'field',
Expand Down Expand Up @@ -339,4 +339,4 @@ def _list_seq_by_group(cli: TrakkaTestCli, group: str):
])

assert result.exit_code == 0, f'Failed to list sequences by group {group} as part of test setup: {result.output}'
return json.loads(result.output)
return json.loads(result.stdout)
2 changes: 1 addition & 1 deletion test/end_to_end_tests/test_proforma_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def _get_proforma_fields(self, proforma_name: str):
'--format',
'json'
])
return json.loads(result.output)
return json.loads(result.stdout)

def test_add_version_no_op_when_spec_is_identical(self):
# Arrange
Expand Down
2 changes: 1 addition & 1 deletion test/end_to_end_tests/test_role_remove_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _role_exists(cli: TrakkaTestCli, role_name: str) -> bool:
# Parse JSON output to check if role exists
import json
try:
roles_data = json.loads(result.output)
roles_data = json.loads(result.stdout)
if isinstance(roles_data, list):
return any(role.get('name') == role_name for role in roles_data)
elif isinstance(roles_data, dict) and 'data' in roles_data:
Expand Down
8 changes: 4 additions & 4 deletions test/end_to_end_tests/test_seq_list_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_list__given_type_is_not_specified__expect_all_types_are_listed(self):

# Assert
assert result.exit_code == 0, f'The seq get command should succeed: {result.output}'
json_result = json.loads(result.output)
json_result = json.loads(result.stdout)

# Count elements by type
fastq_ill_pe_count = sum(1 for item in json_result if item.get("type") == "fastq-ill-pe")
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_list__given_type_is_specified__expect_only_sequence_of_that_type_listed

# Assert
assert result.exit_code == 0, f'The seq get command should succeed: {result.output}'
json_result = json.loads(result.output)
json_result = json.loads(result.stdout)

# Count elements by type
fastq_ill_pe_count = sum(1 for item in json_result if item.get("type") == "fastq-ill-pe")
Expand Down Expand Up @@ -188,7 +188,7 @@ def test_list__given_group_name_is_specified__expect_only_sequences_in_that_grou

# Assert
assert result.exit_code == 0, f'The seq get command should succeed: {result.output}'
json_result = json.loads(result.output)
json_result = json.loads(result.stdout)

# Count elements by type
fastq_ill_pe_count = sum(1 for item in json_result if item.get("type") == "fastq-ill-pe")
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_list__given_seq_id_is_specified__expect_only_sequence_for_the_sample_wi

# Assert
assert result.exit_code == 0, f'The seq get command should succeed: {result.output}'
json_result = json.loads(result.output)
json_result = json.loads(result.stdout)

# Count elements by type
fastq_ill_pe_count = sum(1 for item in json_result if item.get("type") == "fastq-ill-pe")
Expand Down
2 changes: 1 addition & 1 deletion test/utils/trakka_test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _validate(self) -> None:

:raises CliTestException: there is a problem with the provided config
"""
at_uri = os.getenv(TrakkaCxt.get_env_var_name(CxtKey.URI), '')
at_uri = TrakkaCxt.get_env_var_value(CxtKey.URI, '')
if PRODLIKE_DOMAIN in at_uri:
raise CliTestException(f"Unable to run tests against {at_uri}")

Expand Down
11 changes: 6 additions & 5 deletions trakka/components/auth/opts.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import click
from trakka.components.auth.enums import Auth
from trakka.utils.context import CxtKey, TrakkaCxt


def opt_tenant_id(func):
return click.option(
'--tenant-id',
show_envvar=True,
required=True,
envvar='AT_AUTH_TENANT_ID',
envvar=TrakkaCxt.get_env_var_names(CxtKey.AUTH_TENANT_ID),
help='Tenant ID',
default=Auth.TENANT_ID.value,
)(func)
Expand All @@ -18,7 +19,7 @@ def opt_client_id(func):
'--client-id',
show_envvar=True,
required=True,
envvar='AT_AUTH_CLIENT_ID',
envvar=TrakkaCxt.get_env_var_names(CxtKey.AUTH_CLIENT_ID),
help='Client ID',
default=Auth.CLIENT_ID.value,
)(func)
Expand All @@ -29,7 +30,7 @@ def opt_backend_app_uri(func):
'--app-uri',
show_envvar=True,
required=True,
envvar='AT_AUTH_APP_URI',
envvar=TrakkaCxt.get_env_var_names(CxtKey.AUTH_APP_URI),
help='API URI',
default=Auth.APP_SCOPE.value,
)(func)
Expand All @@ -41,7 +42,7 @@ def opt_process_auth_id(func):
'process_id',
show_envvar=True,
required=True,
envvar='AT_AUTH_PROCESS_ID',
envvar=TrakkaCxt.get_env_var_names(CxtKey.AUTH_PROCESS_ID),
help="Process account ID"
)(func)

Expand All @@ -51,6 +52,6 @@ def opt_process_auth_secret(func):
'--secret',
show_envvar=True,
required=True,
envvar='AT_AUTH_PROCESS_SECRET',
envvar=TrakkaCxt.get_env_var_names(CxtKey.AUTH_PROCESS_SECRET),
help='Process account secret'
)(func)
Loading
Loading