Git Product home page Git Product logo

t0xic0der / mdapi Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 5.0 769 KB

A simple and fast API for serving the metadata from the RPM repositories. This repository has now been archived by the owner and moved to https://github.com/fedora-infra/mdapi/tree/develop.

Home Page: https://github.com/fedora-infra/mdapi/tree/develop

License: GNU General Public License v3.0

Python 91.47% HTML 7.84% Dockerfile 0.51% Shell 0.18%
centos fedora hacktoberfest metadata python repositories rpm

mdapi's Introduction

mdapi

A simple and fast API for serving the metadata from the RPM repositories

Installation

For development

  1. Install Python 3, Virtualenv and Poetry on your Fedora Linux installation.
    $ sudo dnf install python3 python3-virtualenv poetry
    
  2. Clone the repository to your local storage and make it your present working directory.
    $ git clone [email protected]:t0xic0der/mdapi.git
    $ cd mdapi
    
  3. Set up and activate a virtual environment within the directory of the cloned repository.
    $ virtualenv venv
    $ source venv/bin/activate
    
  4. Check the validity of the project configuration and install the project dependencies from the lockfile.
    $ (venv) poetry check
    $ (venv) poetry install
    

For container image

  1. Install Podman on your Fedora Linux installation.
    $ sudo dnf install podman
    
  2. Ensure that
    1. The project directory is the present working directory.
    2. The virtual environment with the project is activated, following the instructions provided in the development installation section.
    3. The project configuration is modified according to needs in myconfig.py file, following the instructions provided in the configuration setup section.
  3. Execute the following command to build the container image.
    $ (venv) podman build -t "mdapi:$(poetry version -s)" .
    

Usage

In development

Viewing the help message and version

  1. Ensure that
    1. The project directory is the present working directory.
    2. The virtual environment with the project is activated, following the instructions provided in the development installation section.
  2. Execute the following command to view the help message.
    $ (venv) mdapi --help
    
    Output
    Usage: mdapi [OPTIONS] COMMAND [ARGS]...
    
      A simple API for serving the metadata from the RPM repositories
    
    Options:
      -c, --conffile PATH  Read configuration from the specified Python file
      --version            Show the version and exit.
      --help               Show this message and exit.
    
    Commands:
      database  Fetch SQLite databases from all active Fedora Linux and EPEL...
      serveapp  Start the API server for querying repository metadata
    
  3. Execute the following command to view the project version.
    $ (venv) mdapi --version
    
    Output
    mdapi, version 3.0.0
    

Testing the project

  1. Ensure that
    1. The project directory is the present working directory.
    2. The virtual environment with the project is activated, following the instructions provided in the development installation section.
    3. The storage partition on which test database directory is located has at least 1.5 GiB of free space.
  2. Execute the following command to run the code quality checks and testcases.
    $ (venv) tox
    

Setting up the configuration

  1. Ensure that
    1. The project directory is the present working directory.
  2. Make a copy of the default configuration on your local storage.
    $ cp mdapi/confdata/standard.py mdapi/confdata/myconfig.py
    
  3. Make changes to the copied configuration file to suit the requirements.
    $ nano confdata/myconfig.py
    

Fetching the databases

  1. Ensure that
    1. The project directory is the present working directory.
    2. The virtual environment with the project is activated, following the instructions provided in the development installation section.
    3. The storage partition on which database directory is located has at least 6 GiB of free space.
  2. Execute the following command to start fetching the database, while referencing to the modified configuration file.
    $ (venv) mdapi --conffile myconfig.py database
    
  3. Note that the first run of the database fetching command will take a long time, depending on the internet connection.

Serving the application

  1. Ensure that
    1. The project directory is the present working directory.
    2. The virtual environment with the project is activated, following the instructions provided in the development installation section.
  2. Execute the following command to start serving the application, while referencing to the modified configuration file.
    $ (venv) mdapi --conffile myconfig.py serveapp
    
  3. When done with serving the application, press Ctrl + C to raise a KeyboardInterrupt and exit out of the program.

In container or pod

Serving the application

  1. Ensure that
    1. The project directory is the present working directory.
    2. The virtual environment with the project is activated, following the instructions provided in the development installation section.
    3. The container image is built and available locally.
    4. The databases are downloaded to the database directory, following the instructions provided in the database fetching section.
  2. Execute the following command to start the serving the application.
    $ (venv) podman run -v /var/tmp:/var/tmp -p 8080:8080 -ti mdapi:$(poetry version -s)
    
    This command assumes that the database directory is /var/tmp (which is the default) and the service port is 8080 (which is the default).

mdapi's People

Contributors

ank-22 avatar bstinsonmhk avatar cverna avatar dependabot[bot] avatar gridhead avatar ignatenkobrain avatar lmacken avatar puiterwijk avatar pypingou avatar qulogic avatar ralphbean avatar ryanlerch avatar tyll avatar vividhpandey003 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

mdapi's Issues

Add `setuptools` as a dependency for the project

@Zlopez reported that when he ran mdapi --version command, he faced the following error.

   Traceback (most recent call last):
    File "/var/home/zlopez/git/mdapi/venv/bin/mdapi", line 2, in <module>
      from mdapi.main import main
    File "/var/home/zlopez/git/mdapi/mdapi/main.py", line 30, in <module>
      from mdapi.database.main import index_repositories
    File "/var/home/zlopez/git/mdapi/mdapi/database/main.py", line 36, in <module>
      from fedora_messaging.api import publish
    File "/var/home/zlopez/git/mdapi/venv/lib/python3.10/site-packages/fedora_messaging/api.py", line 10, in <module>
      from . import config, exceptions
    File "/var/home/zlopez/git/mdapi/venv/lib/python3.10/site-packages/fedora_messaging/config.py", line 287, in <module>
      import pkg_resources
  ModuleNotFoundError: No module named 'pkg_resources'

This usually happens when setuptools dependency is not installed or present in the project and hence, it necessitates its addition in the dependency list.

Add code of conduct

In the spirit of getting more contributors to the project, the above document would be appreciated.

Dependency lockfile needs investigation

Many automated dependency updates from https://github.com/dependabot are failing and certain versions of certain dependencies are either not available or are not compatible with other dependencies.

Pull requests affected by this

  1. #78
  2. #79
  3. #80

For now, the workaround employed is ignoring those PRs for now and coming back to them when new PRs for the same dependencies are created for the newer versions. If they pass the CI, the problem would automatically be solved but if not, the dependency lockfile needs to be investigated.

Add more testcases for the CLI parser

Tests that result in expected errors and tests that involve going through the configuration files are needed. If folks want to add more tests atop them, that would be even better.

Add software licensing

Add software licensing

"GPL-3.0-or-later" is compatible with a "GPL-2.0-or-later" code, so front porting the license seems like the right choice here.

Investigate the skipping of the testcases involving downloading the database files

After the reworking of the GitHub Actions config (here), the tests which involve downloading the database files get skipped (as evidenced here).

This is strange and inconsistent, as all occurrences of the tests involving downloading the database files used to work except the first one per job used in the previous test configuration (here). For example,

  1. In this job on Python 3.8 (here), the first (and the only) occurrence (using Python 3.8) of the testcase involving downloading the database files gets skipped (as evidenced here).
  2. In this job on Python 3.9 (here), the first occurrence (using Python 3.8) gets skipped (as evidenced here) but the second occurrence (using Python 3.9) works (as evidenced here).
  3. In this job on Python 3.10 (here), the first occurrence (using Python 3.8) gets skipped (as evidenced here) but the second occurrence (using Python 3.10) works (as evidenced here).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.