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

Add pre-commit hooks #115

Merged
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
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"features": {
"ghcr.io/devcontainers/features/desktop-lite:1": {
"version": "latest"
}, "ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest"
}, "ghcr.io/devcontainers/features/docker-in-docker:2": {
"version": "latest"
}
},
"forwardPorts": [6080],
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install dependencies and app
run: |
poetry install --with lambda-dev
- name: Testing
id: test
run: |
Expand Down
13 changes: 12 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ ci:
autoupdate_schedule: 'quarterly'
skip: [poetry-lock, poetry-export]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: detect-aws-credentials
args: [ --allow-missing-credentials ]
- id: detect-private-key
- id: mixed-line-ending
- id: trailing-whitespace
- id: no-commit-to-branch
args: [--branch, main, --branch, dev]
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
Expand All @@ -20,4 +31,4 @@ repos:
args: [--no-update]
- id: poetry-export
args: ["-f", "requirements.txt", "-o", "sds_data_manager/lambda_code/requirements.txt", "--only", "lambda-dev"]
verbose: true
verbose: true
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# SDS-data-manager

This project is the core of a Science Data System.
This project is the core of a Science Data System.

Our goal with the project is that users will only need to modify the file config.json to define the data products stored on the SDS, and the rest should be mission agnostic.
Our goal with the project is that users will only need to modify the file config.json to define the data products stored on the SDS, and the rest should be mission agnostic.

## Architecture

Expand All @@ -12,17 +12,17 @@ The code in this repository takes the form of an AWS CDK project. It provides th
2. An S3 bucket to contain uploaded files
3. An HTTPS API to query and download files from the S3 bucket (*in development*)
4. A lambda function that inserts file metadata into an opensearch instance
5. A Cognito User Pool that keeps track of who can access the restricted APIs.
5. A Cognito User Pool that keeps track of who can access the restricted APIs.

## Development

The development environment uses a GitHub codespace, to ensure that we're all using the proper libraries as we develop and deploy.
The development environment uses a GitHub codespace, to ensure that we're all using the proper libraries as we develop and deploy.

Everyone gets 50 free hours per month of github Codespace time. Alternatively, your organization can pay for it to run longer than this.
Everyone gets 50 free hours per month of github Codespace time. Alternatively, your organization can pay for it to run longer than this.

To start a new development environment, click the button for "Code" in the upper right corner of the repository, and click "Codespaces".
To start a new development environment, click the button for "Code" in the upper right corner of the repository, and click "Codespaces".

If you are running locally, you will need to install [cdk](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html) and [poetry](https://python-poetry.org/docs/#installation).
If you are running locally, you will need to install [cdk](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html) and [poetry](https://python-poetry.org/docs/#installation).

### Poetry set up
If you're running locally, you can install the Python requirements with Poetry:
Expand Down Expand Up @@ -56,7 +56,7 @@ aws configure

Enter in your AWS Access Key ID and AWS Secret Access Key, which can be obtained by setting up a user account in the AWS console. For region, set it to the AWS region you'd like to set up your SDS. For IMAP, we're using "us-west-2"

If you have multiple AWS access/secret key pairs locally, you can add the configuration to `~/.aws/config`.
If you have multiple AWS access/secret key pairs locally, you can add the configuration to `~/.aws/config`.

```
[imap]
Expand All @@ -71,9 +71,9 @@ Then, you can set the profile used by cdk by setting the `AWS_PROFILE` environme
export AWS_PROFILE=imap
```

You may also need to set the `CDK_DEFAULT_ACCOUNT` environment variable.
You may also need to set the `CDK_DEFAULT_ACCOUNT` environment variable.

**NOTE**-- For new AWS users, you'll need to make certain the AWS Cloud Development Kit is installed:
**NOTE**-- For new AWS users, you'll need to make certain the AWS Cloud Development Kit is installed:

Ensure you have installed nodejs newer than version 14.
<https://nodejs.org/en/download/>
Expand All @@ -83,7 +83,7 @@ nvm use
npm install -g aws-cdk
```

**NOTE**-- If this is a brand-new AWS account (IMPORTANT: new account, not new user), then you'll need to bootstrap your account to allow CDK deployment with the command:
**NOTE**-- If this is a brand-new AWS account (IMPORTANT: new account, not new user), then you'll need to bootstrap your account to allow CDK deployment with the command:

```bash
cdk bootstrap
Expand All @@ -93,7 +93,7 @@ If you get errors with the 'cdk bootstrap' command, running with `-v` will provi

### Deploy

You will need to make a copy of app_template_dev.py file with a different name (app_<name>_dev.py) and keep a copy of it locally so that it will not be committed.
You will need to make a copy of app_template_dev.py file with a different name (app_<name>_dev.py) and keep a copy of it locally so that it will not be committed.
In your own copy there are two important configuration items which you can alter:

1) AWS_PROFILE (<profile>)
Expand All @@ -119,13 +119,13 @@ and then you can deploy the architecture with the following command:
cdk deploy --app "python app_template_dev.py" [ stack | --all ]
```

After about 20 minutes or so, you should have a brand-new SDS set up in AWS.
After about 20 minutes or so, you should have a brand-new SDS set up in AWS.
This is the repository for the cloud infrastructure on the IMAP mission.

**NOTE**-- If you do not intend to use AWS resources for more than a couple of days do a destroy to avoid charges, especially with databases.

```bash
cdk destroy --app "python app_template_dev.py" [ stack | --all ]
cdk destroy --app "python app_template_dev.py" [ stack | --all ]
```

### Virtual Desktop for Development
Expand Down
4 changes: 2 additions & 2 deletions sds_data_manager/config/config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[
{"product": "IMAP-L0-File",
"pattern": {"mission":"imap", "level":"l0", "type":"sci", "instrument":"*", "date":"*", "version":"*", "extension":"pkts"},
"pattern": {"mission":"imap", "level":"l0", "type":"sci", "instrument":"*", "date":"*", "version":"*", "extension":"pkts"},
"path": "imap/l0/"},
{"product": "IMAP-L1-File",
"pattern": {"mission":"imap", "level":"l1", "instrument":"*", "date":"*", "version":"*", "extension":"fits"},
"pattern": {"mission":"imap", "level":"l1", "instrument":"*", "date":"*", "version":"*", "extension":"fits"},
"path": "imap/l1/"}
]