Package: serenata-toolbox
Serenata de Amor Toolboxpipinstallable package to supportSerenata de AmorandRosiedevelopment.Serenata_toolbox is compatible with Python 3.6+Installation$pipinstall-Userenata-toolboxIf you are a regular user you are ready to get started afterpip install.If you are a core developer willing to upload datasets to the cloud you need to configureAMAZON_ACCESS_KEYandAMAZON_SECRET_KEYenvironment variables before running the toolbox.UsageWe haveplenty of themready for you to download from our servers. And this toolbox helps you get them. Here some examples:Example 1: Using the command line wrapper# without any arguments will download our pre-processed datasets and store into data/ folder$serenata-toolbox# will download these specific datasets and store into /tmp/serenata-data folder$serenata-toolbox/tmp/serenata-data--modulefederal_senatechamber_of_deputies# you can specify a dataset and a year$serenata-toolbox--modulechamber_of_deputies--year2009# or specify all options simultaneously$serenata-toolbox/tmp/serenata-data--modulefederal_senate--year2017# getting help$serenata-toolbox--helpExample 2: How do I download the datasets?Another option is creating your own Python script:fromserenata_toolbox.datasetsimportDatasetsdatasets=Datasets('data/')# now lets see what are the latest datasets availablefordatasetindatasets.downloader.LATEST:print(dataset)# and you'll see a long list of datasets!# and let's download one of themdatasets.downloader.download('2018-01-05-reimbursements.xz')# yay, you've just downloaded this dataset to data/# you can also get the most recent version of all datasets:latest=list(datasets.downloader.LATEST)datasets.downloader.download(latest)Example 3: Using shortcutsIf the last example doesn’t look that simple, there are some fancy shortcuts available:fromserenata_toolbox.datasetsimportfetch,fetch_latest_backupfetch('2018-01-05-reimbursements.xz','data/')fetch_latest_backup('data/')# yep, we've just did exactly the same thingExample 4: Generating datasetsIf you ever wonder how did we generated these datasets, this toolbox can help you too (at least with the more used ones — the other ones are generatedin our main repo):fromserenata_toolbox.federal_senate.datasetimportDatasetasSenateDatasetfromserenata_toolbox.chamber_of_deputies.reimbursementsimportReimbursementsasChamberDatasetchamber=ChamberDataset('2018','data/')chamber()senate=SenateDataset('data/')senate.fetch()senate.translate()senate.clean()Documentation (WIP)Thefull documentationis still a work in progress. If you wanna give us a hand you will needSphinx:$cddocs$makeclean;makerst;rmsource/modules.rst;makehtmlContributingFirstly, you should create a development environment with Python’svenvmodule to isolate your development.
Then clone the repository and build the package by running:$gitclonehttps://github.com/okfn-brasil/serenata-toolbox.git$cdserenata-toolbox$pythonsetup.pydevelopAlways add tests to your contribution — if you want to test it locally before opening the PR:$pipinstalltox$toxWhen the tests are passing, also check for coverage of the modules you edited or added — if you want to check it before opening the PR:$tox$openhtmlcov/index.htmlFollowPEP8and best practices implemented byLandscapein theveryhighstrictness level — if you want to check them locally before opening the PR:$pipinstallprospector$prospector-sveryhighserenata_toolboxIf this report includes issues related toimportsection of your files,isortcan help you:$pipinstallisort$isort**/*.py--diffAlways suggest a version bump. We useSemantic Versioning– or inElm community words:MICRO: the API is the same, no risk of breaking codeMINOR: values have been added, existing values are unchangedMAJOR: existing values have been changed or removedThis is really important because every new code merged tomastertriggers the CI and then the CI triggers a new release to PyPI. The attemp to roll out a new version of the toolbox will fail without a version bump. So we do encorouge to add a version bump even if all you have changed is theREADME.rst— this is the way to keep theREADME.rstupdated in PyPI.If you are not changing the API orREADME.rstin any sense and if you really do not want a version bump, you need to add[skip ci]to you commit message.And finally takeThe Zen of Pythoninto account:$python-mthis