Skip to content

Commit

Permalink
Merge pull request #4 from nasa/release/0.5.0
Browse files Browse the repository at this point in the history
Release/0.5.0
  • Loading branch information
frankinspace authored Oct 15, 2021
2 parents ef0f9e7 + 3bf709a commit 3371df0
Show file tree
Hide file tree
Showing 11 changed files with 600 additions and 182 deletions.
71 changes: 71 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ main, develop, feature/* ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main, develop ]
schedule:
- cron: '42 19 * * 5'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
venv/
.idea
*.pyc
tags
tags
.venv
*.egg-info
dist
8 changes: 0 additions & 8 deletions .travis.yml

This file was deleted.

21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.5.0]
### Added
- New support for querying tools (UMM-T) and services (UMM-S)
- CodeQL Analysis on pushes and pull requests
### Changed
- Moved to github.com/nasa/python_cmr

## [Older]
- Prior releases of this software originated from https://github.com/jddeal/python-cmr/releases

[Unreleased]: https://github.com/nasa/python_cmr/compare/v0.5.0...HEAD
[0.5.0]: https://github.com/nasa/python_cmr/compare/ef0f9e7d67ce99d342a568bd6a098c3462df16d2...v0.5.0
[Older]: https://github.com/jddeal/python-cmr/releases
111 changes: 58 additions & 53 deletions README.rst → README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
This repository is a copy of [jddeal/python_cmr](https://github.com/jddeal/python-cmr/tree/ef0f9e7d67ce99d342a568bd6a098c3462df16d2) which is no longer maintained. It has been copied here with the permission of the original author for the purpose of continuing to develop a python library that can be used for CMR access.

----

Python CMR
==========

.. image:: https://travis-ci.org/jddeal/python-cmr.svg?branch=master
:target: https://travis-ci.org/jddeal/python-cmr
[![CodeQL](https://github.com/nasa/python_cmr/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/nasa/python_cmr/actions/workflows/codeql-analysis.yml)

Python CMR is an easy to use wrapper to the NASA EOSDIS
`Common Metadata Repository API <https://cmr.earthdata.nasa.gov/search/>`_. This package aims to make
querying the API intuitive and less error-prone by providing methods that will preemptively check
for invalid input and handle the URL encoding the CMR API expects.
Python CMR is an easy to use wrapper to the NASA EOSDIS [Common Metadata Repository API](https://cmr.earthdata.nasa.gov/search/). This package aims to make querying the API intuitive and less error-prone by providing methods that will preemptively check for invalid input and handle the URL encoding the CMR API expects.

Getting access to NASA's earth science metadata is as simple as this:

::

>>> from cmr import CollectionQuery, GranuleQuery

>>> api = CollectionQuery()
>>> collections = api.archive_center("LP DAAC").keyword("AST_L1*").get(5)

Expand All @@ -33,37 +31,26 @@ Getting access to NASA's earth science metadata is as simple as this:
SC:AST_L1T.003:2149105820
SC:AST_L1T.003:2149155037


Installation
============

To install from pypi:

::

$ pip install python-cmr


To install from github, perhaps to try out the dev branch:

::

$ git clone https://github.com/jddeal/python-cmr
$ cd python-cmr
$ pip install .


Examples
========

This library is broken into two classes, `CollectionQuery` and `GranuleQuery`. Each of these
classes provide a large set of methods used to build a query for CMR. Not all parameters provided
by the CMR API are covered by this version of python-cmr.
This library is broken into two classes, CollectionQuery and GranuleQuery. Each of these classes provide a large set of methods used to build a query for CMR. Not all parameters provided by the CMR API are covered by this version of python-cmr.

The following methods are available to both collecton and granule queries:

::

# search for granules matching a specific product/short_name
>>> api.short_name("AST_L1T")

Expand Down Expand Up @@ -102,11 +89,11 @@ The following methods are available to both collecton and granule queries:
>>> api.concept_id("C1299783579-LPDAAC_ECS")
>>> api.concept_id(["G1327299284-LPDAAC_ECS", "G1326330014-LPDAAC_ECS"])

# search by provider
>>> api.provider('POCLOUD')

Granule searches support these methods (in addition to the shared methods above):

::

# search for a granule by its unique ID
>>> api.granule_ur("SC:AST_L1T.003:2150315169")
# search for granules from a specific orbit
Expand All @@ -121,23 +108,49 @@ Granule searches support these methods (in addition to the shared methods above)
# filter by specific instrument or platform
>>> api.instrument("MODIS")
>>> api.platform("Terra")

Collection searches support these methods (in addition to the shared methods above):

::

# search for collections from a specific archive center
>>> api.archive_center("LP DAAC")

# case insensitive, wildcard enabled text search through most collection fields
>>> api.keyword("M*D09")

# search by native_id
>>> api.native_id('native_id')

As an alternative to chaining methods together to set the parameters of your query, a
method exists to allow you to pass your parameters as keyword arguments:
# filter by tool concept id
>>> api.tool_concept_id('TL2092786348-POCLOUD')

::
# filter by service concept id
>>> api.service_concept_id('S1962070864-POCLOUD')

Service searches support the following methods

# Search via provider
>>> api = ServiceQuery()
>>> api.provider('POCLOUD')

# Search via native_id
>>> api.native_id('POCLOUD_podaac_l2_cloud_subsetter')

# Search via name
>>> api.name('PODAAC L2 Cloud Subsetter')

Tool searches support the following methods

# Search via provider
>>> api = ToolQuery()
>>> api.provider('POCLOUD')

# Search via native_id
>>> api.native_id('POCLOUD_hitide')

# Search via name
>>> api.name('hitide')

As an alternative to chaining methods together to set the parameters of your query, a method exists to allow you to pass your parameters as keyword arguments:

# search for AST_L1T version 003 granules at latitude 42, longitude -100
>>> api.parameters(
Expand All @@ -146,14 +159,10 @@ method exists to allow you to pass your parameters as keyword arguments:
point=(-100, 42)
)

Note: the kwarg key should match the name of a method from the above examples, and the value
should be a tuple if it's a parameter that requires multiple values.

Note: the kwarg key should match the name of a method from the above examples, and the value should be a tuple if it's a parameter that requires multiple values.

To inspect and retreive results from the API, the following methods are available:

::

# inspect the number of results the query will return without downloading the results
>>> print(api.hits())

Expand All @@ -166,30 +175,26 @@ To inspect and retreive results from the API, the following methods are availabl
# retrieve all the granules possible for the query
>>> granules = api.get_all() # this is a shortcut for api.get(api.hits())


By default the responses will return as json and be accessible as a list of python dictionaries.
Other formats can be specified before making the request:

::
By default the responses will return as json and be accessible as a list of python dictionaries. Other formats can be specified before making the request:

>>> granules = api.format("echo10").get(100)

The following formats are supported for both granule and collection queries:

* json (default)
* xml
* echo10
* iso
* iso19115
* csv
* atom
* kml
* native
- json (default)
- xml
- echo10
- iso
- iso19115
- csv
- atom
- kml
- native

Collection queries also support the following formats:

* dif
* dif10
* opendata
* umm_json
* umm_json_vX_Y (ex: umm_json_v1_9)
- dif
- dif10
- opendata
- umm\_json
- umm\_json\_vX\_Y (ex: umm\_json\_v1\_9)
Loading

0 comments on commit 3371df0

Please sign in to comment.