Package: orion-nais
Orion-NAISTable of ContentsAbout The ProjectWhy the nanme Orion?InstallationUsageLocal developmentRequirementsMakefile commandsStructureContributingContactAbout The ProjectOrion-NAIS is a client to work with the NAIS API. It helps with authentication and provides a simple interface to work with the API.When working with the API you need to have a valid token. The token is valid for a set period of time. The client will automatically refresh the token when it expires.Why the name Orion?The NAIS Api is provided through BarentsWatch. BarentsWatch is a Norwegian information portal that provides overview of activity and knowledge in coastal and sea areas. The Norwegian movie "Orion's Belt" from 1985 is an action movie set in the Barents region. About three men, a bulldozer, a Russian helicopter and a ship. Thus the name Orion.InstallationRequires Python 3.10 or later.pipinstallorion-naisor using pipenv:pipenvinstallorion-naisor using poetry:poetryaddorion-naisUsageTo install the package in your project runpoetryaddorion-naisthen add an .env file to your project with the following variables:CLIENT_ID=CLIENT_SECRET=If you don't have a client id and secret you can get one from yourBarentsWatch account.Then you can use the client like this:fromorionimportOrionorion=Orion()# Get the last 24 hours of AIS data for a ship with MMSI XXXXXXXXXXais=orion.get_ais_last_24H(SHIP_MMSI)# Convert the AIS data to a lineline=orion.ais_to_line(ais)Local developmentRequirementspyenv - manage python versionspoetry - manage python dependenciesTo install on mac you can use homebrew:brewupgrade
brewinstallpyenvYou can either install poetry with homebrew or the way described in thedocumentationMakefile commandsmake lintlint the code in the src folder with black, isort and flake8. Mypy will check for correct typing.make formatformat the code in the src folder with black and isort.make testrun the tests in the tests folder.make bump-patchbump the patch version of the package. Example: 0.1.0 -> 0.1.1make bump-minorbump the minor version of the package. Example: 0.1.0 -> 0.2.0make bump-majorbump the major version of the package. Example: 0.1.0 -> 1.0.0make releasepublish the package to pypi. You need to have an account and be logged in to pypi.Structure.
├── .bumpversion.cfg
├── .editorconfig
├── .flake8
├── .gitignore
├── Makefile
├── README.md
├── orion
│   ├── client.py
│   ├── mmsi.py
│   ├── types
│   │   └── ais.py
│   ├── urls.py
│   ├── utils
│   │   └── get_data.py
│   └── vessel_codes.py
├── poetry.lock
├── pyproject.toml
└── tests
    ├── make_mock_data.py
    ├── mocks
    └── test_orion.py.bumpversion.cfgConfiguration file for bumpversion..editorconfigConfiguration file for editorconfig..flake8Configuration file for flake8..gitignoreConfiguration file for git.pyproject.tomlConfiguration file for poetry. Mypy and isort is configured here.poetry.lockLock file for poetry.MakefileMakefile for the project. Here you can find commands for linting and formatting.README.mdThis file.orionThe source code for the package.client.pyThe client class.mmsi.pyA dataclass for handling MMSI numbers and MID-codes (jurisdiction).typesA folder for types.ais.pyA class for handling AIS messages.urls.pyA file with urls for the API.utilsA folder for utility functions.get_data.pyA function for getting data from other sources. Not used by the Orion client. Contains code for getting data from the Norwegian Petroleum Directorate.vessel_codes.pyA dataclass for looking up vessel codes.testsTests for the package.ContributingDo you have write permissions to the repo? Then you can clone this project to a folder on your computer.gitclonehttps://github.com/BergensTidende/orion-nais.gitIf not do the following:Create a personal fork of the project on Github.Clone the fork on your local machine. Your remote repo on Github is calledorigin.Add the original repository as a remote calledupstream.If you created your fork a while ago be sure to pull upstream changes into your local repository.This will clone the repo intoorion-nais.Create a branch for your changesgitcheckout-bname-of-branchMake your changes, rememeber to commit. And always write your commit messages in the present tense. Your commit message should describe what the commit, when applied, does to the code – not what you did to the code.If you're working on a clone push the branch to github and make PR.If your're working a fork:Squash your commits into a single commit with git'sinteractive rebase. Create a new branch if necessary.Push your branch to your fork on Github, the remoteorigin.From your fork open a pull request in the correct branch. Target the project'sdevelopbranch if there is one, else go formaster.If the maintainer requests further changes just push them to your branch. The PR will be updated automatically.Once the pull request is approved and merged you can pull the changes fromupstreamto your local repo and delete
your extra branch(es).ContactBord4 -bord4@bt.no