Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some Windows bugs and tweak docs #134

Merged
merged 7 commits into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on: [push]
jobs:
build:

runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-18.04, ubuntu-latest, macos-10.15, windows-2019]
python-version: [3.6, 3.7, 3.8]

steps:
Expand All @@ -32,10 +33,13 @@ jobs:
env:
CI_PROD_TOKEN: ${{ secrets.CI_PROD_TOKEN }}
CI_DEV_TOKEN: ${{ secrets.CI_DEV_TOKEN }}
shell: bash
run: |
pip install pytest
cd demos
../tests/make-config.sh
ADAM_CONFIG="$PWD/../tests/test-config.yaml" pytest ../tests \
--cov=adam \
--ignore=../tests/integration_tests
ADAM_CONFIG="$(pwd)/../tests/test-config.yaml" pytest ../tests --cov=adam --ignore=../tests/integration_tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ venv/
.DS_Store
.idea/
docsource/
.coverage*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ADAM Python SDK and Jupyter notebooks

[![Python package](https://github.com/B612-Asteroid-Institute/adam_home/workflows/Python%20package/badge.svg)](https://github.com/B612-Asteroid-Institute/adam_home/actions?query=workflow%3A%22Python+package%22)
[![Coverage Status](https://coveralls.io/repos/github/B612-Asteroid-Institute/adam/badge.svg?branch=master)](https://coveralls.io/github/B612-Asteroid-Institute/adam?branch=master)
[![Coverage Status](https://codecov.io/gh/B612-Asteroid-Institute/adam_home)](https://codecov.io/gh/B612-Asteroid-Institute/adam_home)

This repo contains the Python SDK (software development kit) and Jupyter notebooks for interacting with ADAM (Asteroid Decision, Analysis, and Mapping) API programmatically.

Expand Down
8 changes: 6 additions & 2 deletions adam/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ def _do_login(name, url, no_browser):
refresh_token = getpass("Token: ")

if refresh_token:
curr_cfg = cm.get_config(name)
if not curr_cfg:
curr_cfg = None
try:
curr_cfg = cm.get_config(name)
except KeyError:
print(f'Environment {name} does not exist, creating it')
if curr_cfg is None:
curr_cfg = dict(url=url)
curr_cfg['refresh_token'] = refresh_token
cm.set_config(name, curr_cfg)
Expand Down
11 changes: 9 additions & 2 deletions adam/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def _load_raw_config(config_file=None):

Returns
-------
str
The filename of the config
dict
De-serialized configuration in the form of nested dictionaries.

Expand All @@ -44,7 +46,7 @@ def _load_raw_config(config_file=None):
config_file = def_config_file

if config_file is None:
return "", {}
return "", {'envs': {}}

# Load the config file (if we have it)
with open(config_file) as fp:
Expand Down Expand Up @@ -84,7 +86,12 @@ def _store_raw_config(data, config_file=None):
fd = os.open(config_file_tmp, os.O_CREAT | os.O_WRONLY, mode=0o600)
with open(fd, "w") as fp:
yaml.dump(data, fp, indent=2)
os.rename(config_file_tmp, config_file)

try:
os.rename(config_file_tmp, config_file)
except WindowsError:
os.remove(config_file)
os.rename(config_file_tmp, config_file)

return config_file

Expand Down
1 change: 1 addition & 0 deletions adam/opm_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def __init__(self, params):
arg_of_pericenter_deg (float): Argument of pericenter (deg)
true_anomaly_deg (float): True anomaly (deg)
gm (float): Gravitational constant (km^3/s^2)
keplerian_covariance (list): lower triangular covariance matrix (21 elements)

originator (str): responsible entity for run (default: 'ADAM_User')
object_name (str): name of object (default: 'dummy')
Expand Down
1 change: 0 additions & 1 deletion conda-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# conda development environment
astroquery
conda-build
coveralls
flake8
jupyter
matplotlib
Expand Down
2 changes: 2 additions & 0 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy:
- 1.18
2 changes: 2 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ test:
build:
noarch: python
script: python setup.py install --single-version-externally-managed --record=record.txt
entry_points:
- adamctl = adam.__main__:main

about:
home: https://adam.asteroid-institute.org
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# pip development environment
astroquery
coveralls
flake8
jupyter
matplotlib
Expand Down
Binary file removed test_config.json.enc
Binary file not shown.