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

Feature/devcontainer #3

Merged
merged 7 commits into from
Jan 19, 2021
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
8 changes: 3 additions & 5 deletions Dockerfile.dev → .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ COPY . .

RUN python3 setup.py install

RUN core

# Set the default shell to bash instead of sh
# ENV SHELL /bin/bash
EXPOSE 9090

# ENTRYPOINT ./entrypoint.sh
# Run the core system
RUN core
77 changes: 43 additions & 34 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,46 @@
{
"name": "Photos.network Core",
"context": "..",
"dockerFile": "../Dockerfile.dev",
"forwardPorts": [3000],
"postCreateCommand": "mkdir -p config && pip3 install -e .",
"runArgs": ["-e", "GIT_EDITOR=code --wait"],
"extensions": [
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"ms-azure-devops.azure-pipelines",
"redhat.vscode-yaml",
"esbenp.prettier-vscode"
"name": "Photos.network Core",
"build": {
"dockerfile": "Dockerfile.dev",
"context": ".."
},
// forward internal ports to the local machine
// "forwardPorts": [
// 9090
// ],
// Listen on all interfaces
"appPort": 9090,
"postCreateCommand": "mkdir -p config && pip3 install -e .",
"runArgs": [
"-e",
"GIT_EDITOR=code --wait"
],
"extensions": [
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"ms-azure-devops.azure-pipelines",
"redhat.vscode-yaml",
"esbenp.prettier-vscode"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.flake8Enabled": true,
"python.linting.flake8Path": "/usr/local/bin/flake8",
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.testing.pytestArgs": [
"--no-cov"
],
"settings": {
"python.pythonPath": "/usr/local/bin/python",
"python.linting.pylintEnabled": true,
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.testing.pytestArgs": ["--no-cov"],
"python.testing.pytestEnabled": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.shell.linux": "/bin/bash",
"yaml.customTags": [
"!input scalar",
"!secret scalar",
"!include_dir_named scalar",
"!include_dir_list scalar",
"!include_dir_merge_list scalar",
"!include_dir_merge_named scalar"
]
}
"python.testing.pytestEnabled": true,
"python.formatting.blackArgs": [
"--line-length",
"120"
],
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"terminal.integrated.shell.linux": "/bin/bash",
}
}
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: [3.8, 3.9]

steps:
- name: Checkout
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ share/*
.vscode/*
!.vscode/cSpell.json
!.vscode/extensions.json
!.vscode/launch.json
!.vscode/settings.default.json
!.vscode/tasks.json
.env

Expand Down
59 changes: 59 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
hooks:
- id: pyupgrade
args: [--py37-plus]

- repo: https://github.com/psf/black
rev: 20.8b1
hooks:
- id: black
args:
- --safe
- --quiet
files: ^((core|tests)/.+)?[^/]+\.py$

- repo: https://github.com/codespell-project/codespell
rev: v1.17.1
hooks:
- id: codespell
args:
- --ignore-words-list=referer,visability,withing
- --skip="./.*,*.csv,*.json"
- --quiet-level=2
exclude_types: [csv, json]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
hooks:
- id: flake8
additional_dependencies:
- flake8-docstrings==1.5.0
- pydocstyle==5.0.2
files: ^(core|tests)/.+\.py$

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.6.4
hooks:
- id: isort
args:
- --line-width=88
- --trailing-comma
- -m=3

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-executables-have-shebangs
stages: [manual]
- id: check-json

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
hooks:
- id: mypy
args:
- --pretty
- --show-error-codes
- --show-error-context
5 changes: 4 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"recommendations": ["esbenp.prettier-vscode", "ms-python.python"]
"recommendations": [
"esbenp.prettier-vscode",
"ms-python.python"
]
}
19 changes: 19 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.1.0",
"configurations": [
{
"name": "Photos.network",
"type": "python",
"request": "launch",
"module": "core",
"args": [
"--debug",
"-c",
"config"
]
}
]
}
8 changes: 8 additions & 0 deletions .vscode/settings.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.formatting.provider": "black",
// Added --no-cov to work around TypeError: message must be set
// https://github.com/microsoft/vscode-python/issues/14067
"python.testing.pytestArgs": ["--no-cov"],
// https://code.visualstudio.com/docs/python/testing#_pytest-configuration-settings
"python.testing.pytestEnabled": true
}
12 changes: 8 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
"version": "2.0.0",
"tasks": [
{
"label": "Pytest",
"label": "Pytest",
"type": "shell",
"command": "pytest --timeout=10 tests",
"dependsOn": ["Install all Test Requirements"],
"dependsOn": [
"Install all Test Requirements"
],
"group": {
"kind": "test",
"isDefault": true
Expand Down Expand Up @@ -34,7 +36,9 @@
"label": "Pylint",
"type": "shell",
"command": "pylint photos",
"dependsOn": ["Install all Requirements"],
"dependsOn": [
"Install all Requirements"
],
"group": {
"kind": "test",
"isDefault": true
Expand All @@ -45,7 +49,7 @@
},
"problemMatcher": []
},
{
{
"label": "Install all Requirements",
"type": "shell",
"command": "pip3 install -r requirements_all.txt",
Expand Down
51 changes: 21 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Its core features are:
- Filter / Search photos by attributes like location or date
- Group photos by objects like people of objects


## Core
This repository contains the core system of the project.
It is responsible for main tasks e.g.:
Expand All @@ -21,45 +22,34 @@ It is responsible for main tasks e.g.:
- **Persistency** (read / write data)
- **Task Processing** (keep track of running tasks)

### Add-ons
The core system can be extended by add-ons to attune user needs.

Each addon is encapsulated in a separate directory wich have to contain at least:
- `addon.json` with detailed informations and requirements
- `__init__.py` with an async setup function

```json
{
"domain": "api",
"name": "REST api",
"requirements": [],
"core": "0.1.0"
}
## Installation
Install core dependencies:
```shell
$ pip3 install -r requirements.txt
```

```python
async def async_setup(core: ApplicationCore, config: dict) -> bool:
return True
Install the core system from the wheel
```shell
$ pip3 install --upgrade --force-reinstall core-0.1.0-py3-none-any.whl
```


- Sync photos (reading & writing)
- server <=> server
- nextcloud, gdrive, icloud
- client <=> server
- browser, native app
- File processing
- Metadata parsing
- Image processing
- Object detection
- Face detection
## Development
Always use [PEP 484: Type Hints](https://www.python.org/dev/peps/pep-0484/) in your syntax.


### Visual Studio Code
The fastest start into development can be archived by using [Visual Studio Code](https://code.visualstudio.com/) and [Docker](https://www.docker.com/get-started).

1. Install [Docker](https://www.docker.com/get-started)
2. Install [Visual Studio Code](https://code.visualstudio.com/)
3. Install [Visual Studio Code Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers)
4. Clone and Open this repository in Visual Studio Code
5. Click the "Reopen in Container" Dialog

## Development
Always use [PEP 484: Type Hints](https://www.python.org/dev/peps/pep-0484/) in your syntax.

#### Prepare setup
### Manual Environment
Prepare an environment by running:
```shell
python3 -m venv venv
Expand All @@ -72,7 +62,8 @@ After the environment is build, install the core:
python3 setup.py install
```

#### Run

## Run
```shell
python3 ./venv/bin/core
```
10 changes: 1 addition & 9 deletions config/configuration.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"internal_url": "192.168.0.1",
"external_url": "external.url.com",
"port": 9090,
"data_dir": "data",
"addons": [
{
Expand All @@ -14,15 +15,6 @@
"config": {
"database_file": "test.sqlite"
}
},
{
"name": "metadata"
},
{
"name": "nextcloud"
},
{
"name": "places365"
}
]
}
29 changes: 29 additions & 0 deletions config/configuration.json.bak
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"internal_url": "192.168.0.1",
"external_url": "external.url.com",
"port": 9090,
"data_dir": "data",
"addons": [
{
"name": "api",
"config": {
"cors": false
}
},
{
"name": "sqlite",
"config": {
"database_file": "test.sqlite"
}
},
{
"name": "metadata"
},
{
"name": "nextcloud"
},
{
"name": "places365"
}
]
}
2 changes: 1 addition & 1 deletion core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""init"""
"""init of Photos.network core."""
Loading