Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ All supported arguments:
specify the version of the tool this submission is done with
--no_data_upload indicate if no upload should be performed and you like to submit a RUN object (e.g. if uploaded was done separately).
--draft indicate if no submission should be performed
--secret SECRET .secret.yml file containing the password and Webin ID of your ENA account
--secret SECRET .secret.yml file containing the password and Webin ID of your ENA account OR set ENA_USER and ENA_PASS env variables
-d, --dev flag to use the dev/sandbox endpoint of ENA
```

Expand All @@ -88,10 +88,17 @@ Mandatory arguments: --action, --center and --secret.

A Webin can be made [here](https://www.ebi.ac.uk/ena/submit/sra/#home) if you don't have one already. The Webin ID makes use of the full username looking like: `Webin-XXXXX`. Visit [Webin online](https://www.ebi.ac.uk/ena/submit/webin) to check on your submissions or [dev Webin](https://wwwdev.ebi.ac.uk/ena/submit/webin) to check on test submissions.

### The .secret.yml file
### Credentials
There are two supported ways to provide your ENA credentials.

#### The .secret.yml file

To avoid exposing your credentials through the terminal history, it is recommended to make use of a `.secret.yml` file, containing your password and username keywords. An example is given in the root of this directory.

#### Environment variables

Alternatively, credentials can be provided via environment variables. Set the variables ENA_USER and ENA_PASS in your environment and run the tool without the --secret option.

### ENA sample checklists

You can specify ENA sample checklist using the `--checklist` parameter. By default the ENA default sample checklist is used supporting the minimum information required for the sample (ERC000011). The supported checklists are listed on our [template repo](https://github.com/ELIXIR-Belgium/ENA-metadata-templates).
Expand Down
34 changes: 23 additions & 11 deletions ena_upload/ena_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ def process_args():
help='indicate if no submission should be performed')

parser.add_argument('--secret',
required=True,
help='.secret.yml file containing the password and Webin ID of your ENA account')
required=False,
help='.secret.yml file containing the password and Webin ID of your ENA account OR set ENA_USER and ENA_PASS env variables')

parser.add_argument(
'-d', '--dev', help="flag to use the dev/sandbox endpoint of ENA", action="store_true")
Expand All @@ -792,8 +792,14 @@ def process_args():
if tables == {None} and not args.xlsx and not args.isa_json:
parser.error('Requires at least one table for submission')

# check if .secret file exists
if args.secret:
# check credentials source
if not args.secret:
if not (os.environ.get('ENA_USER') and os.environ.get('ENA_PASS')):
parser.error(
f"Credentials required: provide --secret or set "
f"ENA_USER and ENA_PASS environment variables"
)
else:
if not os.path.isfile(args.secret):
msg = f"Oops, the file {args.secret} does not exist"
parser.error(msg)
Expand Down Expand Up @@ -868,16 +874,22 @@ def main():
isa_assay_stream = args.isa_assay_stream
auto_action = args.auto_action

with open(secret, 'r') as secret_file:
credentials = yaml.load(secret_file, Loader=yaml.FullLoader)
if secret:
with open(secret, 'r') as secret_file:
credentials = yaml.load(secret_file, Loader=yaml.FullLoader)
password = credentials.get('password', '').strip()
webin_id = credentials.get('username', '').strip()
else:
webin_id = os.environ.get('ENA_USER', '').strip()
Comment thread
RZ9082 marked this conversation as resolved.
Outdated
password = os.environ.get('ENA_PASS', '').strip()

password = credentials['password'].strip()
webin_id = credentials['username'].strip()

if not password or not webin_id:
print(
f"Oops, file {args.secret} does not contain a password or username")
secret_file.close()
sys.exit(
"Oops, missing ENA credentials (username or password). "
"Provide --secret or set ENA_USER and ENA_PASS."
)


if xlsx:
# create dataframe from xlsx table
Expand Down
Loading