Skip to content

Commit

Permalink
Add pylint (#143)
Browse files Browse the repository at this point in the history
* add pylint check to repo
  • Loading branch information
nikita-b authored Dec 22, 2022
1 parent 490b148 commit 78452b6
Show file tree
Hide file tree
Showing 41 changed files with 717 additions and 533 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Lint

on:
push:
branches:
- master
pull_request:
workflow_dispatch:


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Dependencies
shell: bash
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pylint==2.15.8
- name: Lint
shell: bash
run: |
pylint nomad/
3 changes: 0 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ jobs:
NOMAD_VERSION: ${{ matrix.nomad-version }}
shell: bash
run: |
echo $NOMAD_VERSION
echo ${NOMAD_VERSION}
echo "downloading nomad"
Expand All @@ -50,8 +49,6 @@ jobs:
/tmp/nomad agent -dev -bind ${NOMAD_IP} -node pynomad1 --acl-enabled > /dev/null 2>&1 &
sleep 30
- name: Install Dependencies
env:
PYTHON_VERSION: ${{ matrix.python-version }}
shell: bash
run: |
python -m pip install --upgrade pip
Expand Down
6 changes: 6 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[FORMAT]
# Maximum number of characters on a single line.
max-line-length=120

[MESSAGES CONTROL]
disable=duplicate-code
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## 2.0.0 (unreleased)
* Up `requests` lib version to 2.28.1
### BREAKING CHANGES
* Drop Python 2 and Python 3.6 support
* Rename `id` arguments to `_id` across of code base
### Other changes
* Up `requests` lib version to 2.28.1

## 1.5.0
* Add `namespace` agrument support for `get_allocations` and `get_deployments` endpoints (#133)
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class <Endpoint>(Requester):
ENDPOINT = "<endpoint>"

def __init__(self, **kwargs):
super(<Endpoint>, self).__init__(**kwargs)
super().__init__(**kwargs)
```

##### Entity
Expand Down Expand Up @@ -249,7 +249,7 @@ class cat(Requester):
ENDPOINT = "client/fs/cat"

def __init__(self, **kwargs):
super(cat, self).__init__(**kwargs)
super().__init__(**kwargs)

def read_file(self, id=None, path="/"):
""" Read contents of a file in an allocation directory.
Expand Down Expand Up @@ -382,7 +382,7 @@ class <Endpoint>(Requester):
ENDPOINT = "<endpoint>"

def __init__(self, **kwargs):
super(<Endpoint>, self).__init__(**kwargs)
super().__init__(**kwargs)

def __str__(self):
return "{0}".format(self.__dict__)
Expand Down
105 changes: 99 additions & 6 deletions nomad/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import nomad.api as api
"""Nomad Python library"""
import os

from nomad import api

class Nomad(object):

def __init__(self,
class Nomad(): # pylint: disable=too-many-public-methods,too-many-instance-attributes
"""
Nomad API
"""
def __init__(self, # pylint: disable=too-many-arguments
host='127.0.0.1',
secure=False,
port=4646,
Expand Down Expand Up @@ -102,122 +105,212 @@ def __init__(self,
self._variables = api.Variables(**self.requester_settings)

def get_uri(self):
"""
Get Nomad host
"""
if self.secure:
protocol = "https"
else:
protocol = "http"
return "{protocol}://{host}".format(protocol=protocol, host=self.host)
return f"{protocol}://{self.host}"

def get_namespace(self):
"""
Get Nomad namaspace
"""
return self.__namespace

def get_token(self):
"""
Get Nomad token
"""
return self.token

@property
def jobs(self):
"""
Jobs API
"""
return self._jobs

@property
def job(self):
"""
Job API
"""
return self._job

@property
def nodes(self):
"""
Nodes API
"""
return self._nodes

@property
def node(self):
"""
Node API
"""
return self._node

@property
def allocations(self):
"""
Allocations API
"""
return self._allocations

@property
def allocation(self):
"""
Allocation API
"""
return self._allocation

@property
def evaluations(self):
"""
Evaluations API
"""
return self._evaluations

@property
def evaluation(self):
"""
Evaluation API
"""
return self._evaluation

@property
def event(self):
"""
Event API
"""
return self._event

@property
def agent(self):
"""
Agent API
"""
return self._agent

@property
def client(self):
"""
Client API
"""
return self._client

@property
def deployments(self):
"""
Deployments API
"""
return self._deployments

@property
def deployment(self):
"""
Deployment API
"""
return self._deployment

@property
def regions(self):
"""
Regions API
"""
return self._regions

@property
def scaling(self):
"""
Scaling API
"""
return self._scaling

@property
def status(self):
"""
Status API
"""
return self._status

@property
def system(self):
"""
System API
"""
return self._system

@property
def operator(self):
"""
Operator API
"""
return self._operator

@property
def validate(self):
"""
Validate API
"""
return self._validate

@property
def namespaces(self):
"""
Namespaces API
"""
return self._namespaces

@property
def namespace(self):
"""
Namespace API
"""
return self._namespace

@property
def acl(self):
"""
ACL API
"""
return self._acl

@property
def sentinel(self):
"""
Sentinel API
"""
return self._sentinel

@property
def search(self):
"""
Search API
"""
return self._search

@property
def metrics(self):
"""
Metrics API
"""
return self._metrics

@property
def variable(self):
"""
Variable API
"""
return self._variable

@property
def variables(self):
return self._variables
"""
Variables API
"""
return self._variables
3 changes: 2 additions & 1 deletion nomad/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Nomad Python library"""
import nomad.api.exceptions
from nomad.api.acl import Acl
from nomad.api.agent import Agent
Expand Down Expand Up @@ -26,4 +27,4 @@
from nomad.api.system import System
from nomad.api.validate import Validate
from nomad.api.variable import Variable
from nomad.api.variables import Variables
from nomad.api.variables import Variables
Loading

0 comments on commit 78452b6

Please sign in to comment.