Skip to content

Commit

Permalink
fix: optimize docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jerlendds committed Apr 15, 2023
1 parent d8ecaf2 commit fa05f4a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 66 deletions.
10 changes: 1 addition & 9 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
# Microsoft Open Source Code of Conduct

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).

Resources:

- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
@todo
48 changes: 2 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The plugins library for [jerlendds/osintbuddy](https://github.com/jerlendds/osintbuddy), coming soon...


This project follows the Python Standards declared in PEP 621. It uses a pyproject.yaml file to configure the project and Flit to simplify the build process and publish to PyPI. Flit simplifies the build and packaging process for Python projects by eliminating the need for separate setup.py and setup.cfg files. With Flit, you can manage all relevant configurations within the pyproject.toml file, streamlining development and promoting maintainability by centralizing project metadata, dependencies, and build specifications in one place.
This project follows the Python Standards declared in PEP 621. It uses a pyproject.yaml file to configure the project and Flit to simplify the build process and publish to PyPI.

## Extending OSINTBuddy with extension/plugins

Expand All @@ -19,48 +19,4 @@ This project follows the Python Standards declared in PEP 621. It uses a pyproje
- `.github/workflows`: Contains GitHub Actions used for building, testing, and publishing.
- `src`: Place new source code here.
- `tests`: Contains Python-based test cases to validate source code.
- `pyproject.toml`: Contains metadata about the project and configurations for additional tools used to format, lint, type-check, and analyze Python code.

#### Tool Sections

##### black

Black is a Python code formatter that automatically reformats Python code to conform to the PEP 8 style guide. It is used to maintain a consistent code style throughout the project.

The pyproject.toml file specifies the maximum line length and whether or not to use a "fast" mode for formatting. Black also allows for a pyproject.toml configuration file to be included in the project directory to customize its behavior.

##### coverage

Coverage is a tool for measuring code coverage during testing. It generates a report of which lines of code were executed during testing and which were not.

The pyproject.toml file specifies that branch coverage should be measured and that the tests should fail if the coverage falls below 100%. Coverage can be integrated with a variety of test frameworks, including pytest.

##### pytest

Pytest is a versatile testing framework for Python projects that simplifies test case creation and execution. It supports both pytest-style and unittest-style tests, offering flexibility in testing approaches. Key features include fixture support for clean test environments, parameterized tests to reduce code duplication, and extensibility through plugins for customization. Adopt pytest to streamline testing and tailor the framework to your project's specific needs.

The pyproject.toml file plays an essential role in configuring pytest for your project. It includes various test markers, such as integration, notebooks, gpu, spark, slow, and unit, which are used during testing. It also specifies options for generating test coverage reports, setting the Python path, and outputting test results in the xunit2 format. You can easily modify the pyproject.toml file to customize pytest for your project's specific needs.

##### pylint

Pylint is a versatile Python linter and static analysis tool that identifies errors and style issues in your code. It generates an in-depth report, presenting errors, warnings, and conventions found in the codebase. Pylint configurations are centralized in the pyproject.toml file, covering extension management, warning suppression, output formatting, and code style settings such as maximum function arguments and class attributes. The unique scoring system provided by Pylint helps developers assess and maintain code quality, ensuring a focus on readability and maintainability throughout the project's development.

##### pyright

Pyright is a static type checker for Python that uses type annotations to analyze your code and catch type-related errors. It is capable of analyzing Python code that uses type annotations as well as code that uses docstrings to specify types.

The pyproject.toml file contains configurations for Pyright, such as the directories to include or exclude from analysis, the virtual environment to use, and various settings for reporting missing imports and type stubs. By using Pyright, you can catch errors related to type mismatches before they even occur, which can save you time and improve the quality of your code.

##### flake8

Flake8 is a code linter for Python that checks your code for style and syntax issues. It checks your code for PEP 8 style guide violations, syntax errors, and more.

The pyproject.toml file contains configurations for Flake8, such as the maximum line length, which errors to ignore, and which style guide to follow. By using Flake8, you can ensure that your code follows the recommended style guide and catch syntax errors before they cause problems.

##### tox

In our repository, we use Tox to automate testing and building our Python package across various environments and versions. Configured through the pyproject.toml file, Tox is set up with four testing environments: py, integration, spark, and all. Each environment targets specific test categories or runs all tests together, ensuring compatibility and functionality in different scenarios.

The [tool.tox] section in the pyproject.toml file contains the Tox configuration details, including the legacy_tox_ini attribute. Our setup outlines the dependencies needed for each environment, as well as the test runner (e.g., pytest) and any associated commands. This ensures consistent test execution across all environments.

Tox helps us efficiently automate testing and building processes, maintaining the reliability and functionality of our Python package across a wide range of environments. By identifying potential compatibility issues early in the development process, we improve the quality and usability of our package. Our Tox configuration streamlines the development workflow, promoting code quality and consistency throughout the project.
- `pyproject.toml`: Contains metadata about the project and configurations for additional tools used to format, lint, type-check, and analyze Python code.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ test = [

[project.urls]
Documentation = "https://docs-osintbuddy-com.vercel.app/"
Source = "https://github.com/jerlendds/osintbuddy"
Source = "https://github.com/jerlendds/plugins.osintbuddy.com"
Tracker = "https://github.com/jerlendds/osintbuddy/issues"

[tool.flit.module]
Expand Down
6 changes: 4 additions & 2 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

The plugins library for [jerlendds/osintbuddy](https://github.com/jerlendds/osintbuddy), coming soon...

## Extending OSINTBuddy with extension/plugins
## Extending OSINTBuddy with extensions/plugins

@todo

## Creating a plugin with dependent plugins...
## Creating an extension thats dependent on other plugins...

@todo

## Creating custom nodes
4 changes: 1 addition & 3 deletions src/osintbuddy/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@ def __init__(self) -> None:
self.repository: str = None
self.authors = List[str]
self._base_plugin_endpoint = slugify(self.node_name)
self._endpoints = self.generate_endpoints()
self._router: APIRouter = APIRouter(prefix=self._base_plugin_endpoint)
self._generate_endpoints()

def request(self, transform: str, **kwargs):
return self.transforms[transform](**kwargs)

def _generate_endpoints(self):
if self.transforms is None:
return
endpoints = []
for transform in self.transforms.keys():
route = str.encode(
f"{self._base_plugin_endpoint}{transform}{self.repository}"
Expand All @@ -35,7 +34,6 @@ def _generate_endpoints(self):
endpoint_route,
endpoint=self.transforms[transform]
)
return endpoints


class Plugin(BasePlugin):
Expand Down
2 changes: 0 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

from __future__ import annotations

from typing import List

import pytest
from _pytest.nodes import Item

Expand Down
4 changes: 1 addition & 3 deletions tests/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
"""This is a sample python file for testing functions from the source code."""
from __future__ import annotations

from osintbuddy.plugins import osintbuddy


def osintbuddy_test():
"""
This defines the expected usage, which can then be used in various test cases.
Pytest will not execute this code directly, since the function does not contain the suffex "test"
"""
osintbuddy()
pass

0 comments on commit fa05f4a

Please sign in to comment.