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

Remove custom command line interface #28

Merged
merged 1 commit into from
Apr 3, 2024
Merged
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
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,23 @@ The recommended method of installation is through the [`pip`](https://pip.pypa.i

## Setup

To use one of the storage backends provided by `aiida-s3` with AiiDA, you need to create a profile for it:
To use one of the storage backends provided by `aiida-s3` with AiiDA, you need to create a profile for it.
This can be done through AiiDA's CLI `verdi`:

1. List the available storage backends:
```bash
aiida-s3 profile setup --help
verdi profile setup --help
```

1. Create a profile using one of the available storage backends by passing it as an argument to `aiida-s3 profile setup`, for example:
1. Create a profile using one of the available storage backends by passing it as an argument to `verdi profile setup`, for example:
```bash
aiida-s3 profile setup s3.psql_s3
verdi profile setup s3.psql_s3
```
The command will prompt for the information required to setup the storage backend.
After all information is entered, the storage backend is initialized, such as creating the database schema and creating file containers.

1. Create a default user for the profile:
```bash
verdi -p profile-name user configure --set-default
```

1. The profile is now ready to be used with AiiDA.
Optionally, you can set it as the new default profile:
```bash
verdi profile setdefault profile-name
```

1. Optionally, to test that everything is working as intended, launch a test calculation:
Optionally, to test that everything is working as intended, launch a test calculation:
```bash
verdi -p profile-name devel launch-add
```
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ classifiers = [
'Topic :: Scientific/Engineering'
]
dependencies = [
'aiida-core~=2.4.0',
'aiida-core~=2.5.0',
'azure-storage-blob',
'boto3'
]
Expand Down
12 changes: 0 additions & 12 deletions src/aiida_s3/cli/__init__.py

This file was deleted.

92 changes: 0 additions & 92 deletions src/aiida_s3/cli/cmd_profile.py

This file was deleted.

60 changes: 23 additions & 37 deletions src/aiida_s3/storage/psql_aws_s3.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Implementation of :class:`aiida.orm.implementation.storage_backend.StorageBackend` using PostgreSQL + AWS S3."""
from __future__ import annotations

import typing as t
from aiida.storage.psql_dos import PsqlDosBackend
from pydantic import Field

from ..repository.aws_s3 import AwsS3RepositoryBackend
from .psql_dos import BasePsqlDosBackend
from .psql_s3 import PsqlS3StorageMigrator


Expand All @@ -26,48 +26,34 @@ def get_repository(self) -> AwsS3RepositoryBackend:
)


class PsqlAwsS3Storage(BasePsqlDosBackend):
class PsqlAwsS3Storage(PsqlDosBackend):
"""Storage backend using PostgresSQL and AWS S3."""

migrator = PsqlAwsS3StorageMigrator

class Configuration(PsqlDosBackend.Configuration):
"""Model describing required information to configure an instance of the storage."""

aws_access_key_id: str = Field(
title='AWS access key ID',
description='The AWS access key ID.',
)
aws_secret_access_key: str = Field(
title='AWS secret access key',
description='The AWS secret access key.',
)
aws_region_name: str = Field(
title='AWS region',
description='The AWS region name code, e.g., `eu-central-1`.',
)
aws_bucket_name: str = Field(
title='AWS bucket name',
description='The name of the AWS S3 bucket to use.',
)

def get_repository(self) -> AwsS3RepositoryBackend: # type: ignore[override]
"""Return the file repository backend instance.

:returns: The repository of the configured profile.
"""
return self.migrator(self.profile).get_repository()

@classmethod
def _get_cli_options(cls) -> dict[str, t.Any]:
"""Return the CLI options that would allow to create an instance of this class."""
options = super()._get_cli_options()
options.update(
**{
'aws_access_key_id': {
'required': True,
'type': str,
'prompt': 'AWS access key ID',
'help': 'The AWS access key ID.',
},
'aws_secret_access_key': {
'required': True,
'type': str,
'prompt': 'AWS secret access key',
'help': 'The AWS secret access key.',
},
'aws_region_name': {
'required': True,
'type': str,
'prompt': 'AWS region',
'help': 'The AWS region name code, e.g., `eu-central-1`.',
},
'aws_bucket_name': {
'required': True,
'type': str,
'prompt': 'AWS bucket name',
'help': 'The name of the AWS S3 bucket to use.',
},
}
)
return options
40 changes: 15 additions & 25 deletions src/aiida_s3/storage/psql_azure_blob.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Implementation of :class:`aiida.orm.implementation.storage_backend.StorageBackend` using PostgreSQL + Azure."""
from __future__ import annotations

import typing as t
from aiida.storage.psql_dos.backend import PsqlDosBackend
from pydantic import Field

from ..repository.azure_blob import AzureBlobStorageRepositoryBackend
from .psql_dos import BasePsqlDosBackend
from .psql_s3 import PsqlS3StorageMigrator


Expand All @@ -30,36 +30,26 @@ def get_repository(self) -> AzureBlobStorageRepositoryBackend: # type: ignore[o
)


class PsqlAzureBlobStorage(BasePsqlDosBackend):
class PsqlAzureBlobStorage(PsqlDosBackend):
"""Storage backend using PostgresSQL and Azure Blob Storage."""

migrator = PsqlAzureBlobStorageMigrator

class Configuration(PsqlDosBackend.Configuration):
"""Model describing required information to configure an instance of the storage."""

container_name: str = Field(
title='Container name',
description='The Azure Blob Storage container name.',
)
connection_string: str = Field(
title='Connection string',
description='The Azure Blob Storage connection string.',
)

def get_repository(self) -> AzureBlobStorageRepositoryBackend: # type: ignore[override]
"""Return the file repository backend instance.

:returns: The repository of the configured profile.
"""
return self.migrator(self.profile).get_repository()

@classmethod
def _get_cli_options(cls) -> dict[str, t.Any]:
"""Return the CLI options that would allow to create an instance of this class."""
options = super()._get_cli_options()
options.update(
**{
'container_name': {
'required': True,
'type': str,
'prompt': 'Container name',
'help': 'The Azure Blob Storage container name.',
},
'connection_string': {
'required': True,
'type': str,
'prompt': 'Connection string',
'help': 'The Azure Blob Storage connection string.',
},
}
)
return options
80 changes: 0 additions & 80 deletions src/aiida_s3/storage/psql_dos.py

This file was deleted.

Loading
Loading