Skip to content

Commit

Permalink
add pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ehneilsen committed Sep 15, 2023
1 parent 08321f3 commit ee2945f
Show file tree
Hide file tree
Showing 50 changed files with 210 additions and 261 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "util/sims_featureScheduler_runs3.0"]
path = util/sims_featureScheduler_runs3.0
url = https://github.com/lsst-sims/sims_featureScheduler_runs3.0.git
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
- repo: https://github.com/psf/black
rev: 23.7.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
language_version: python3.11
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.278
hooks:
- id: ruff
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"python.testing.pytestEnabled": true,
"python.envFile": "${workspaceFolder}/.env",
"python.formatting.provider": "black"
}
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ The `schedview` module provides tools for visualizing Rubin Observatory schedule

- A collection of functions, eacho of which creates an independent visualization of same aspect of scheduler behaviour, state, or surve progress. These functions may be used in `jupyter` notebooks or other python applications, or combined into dashboards or other higher level applications.
- A handful of dashboard applications that collect relevant visualizations into sets suitable for specific use cases.

2 changes: 1 addition & 1 deletion notebooks/custom_plot.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
]
}
}
]
]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "schedview"
description = "Tools for visualization of Rubin Observatory's scheduler status, strategy and progress on LSST."
classifiers = [
classifiers = [
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
Expand Down
35 changes: 18 additions & 17 deletions schedview/app/prenight/prenight.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
import argparse
import param
import importlib
import json
import logging
import os

import astropy.utils.iers
import bokeh
import hvplot.pandas # noqa: F401
import numpy as np
import pandas as pd
import os
import json
import importlib
import panel as pn
import bokeh
import hvplot.pandas
import param
import rubin_sim.scheduler.example
from astropy.time import Time
import astropy.utils.iers

from rubin_sim.scheduler.model_observatory import ModelObservatory
import rubin_sim.scheduler.example

import schedview.compute.astro
import schedview.collect.footprint
import schedview.collect.opsim
import schedview.compute.astro
import schedview.compute.scheduler
import schedview.collect.footprint
import schedview.plot.visits
import schedview.plot.visitmap
import schedview.plot.rewards
import schedview.plot.visits
import schedview.param
import schedview.plot.nightbf
import schedview.plot.nightly
import schedview.param
import schedview.plot.rewards
import schedview.plot.visitmap
import schedview.plot.visits

AVAILABLE_TIMEZONES = [
"Chile/Continental",
Expand Down Expand Up @@ -853,7 +852,9 @@ def make_app(
Returns
-------
pn_app : `panel.viewable.Viewable` or `tuple` ['panel.viewable.Viewable', `schedview.prenight.Prenight`]
pn_app : `panel.viewable.Viewable`
or `tuple`
['panel.viewable.Viewable', `schedview.prenight.Prenight`]
The pre-night briefing app.
"""
prenight = cls()
Expand Down
3 changes: 2 additions & 1 deletion schedview/app/sched_maps/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from schedview.app.sched_maps.sched_maps import add_scheduler_map_app
import bokeh

from schedview.app.sched_maps.sched_maps import add_scheduler_map_app

doc = bokeh.plotting.curdoc()
add_scheduler_map_app(doc)
31 changes: 13 additions & 18 deletions schedview/app/sched_maps/sched_maps.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
import bokeh.core.properties
import bokeh.models
import bokeh.plotting
from astropy.time import Time

import pandas as pd
import bokeh.models
import bokeh.core.properties

from uranography.api import (
ArmillarySphere,
HorizonMap,
Planisphere,
MollweideMap,
)

from schedview.collect import sample_pickle

from schedview.plot.scheduler import SchedulerDisplay
from rubin_sim.scheduler.model_observatory import ModelObservatory
from schedview.collect import read_scheduler
from schedview.plot.scheduler import LOGGER, DEFAULT_NSIDE, DEFAULT_MJD
import rubin_sim.scheduler.example
from astropy.time import Time
from rubin_sim.scheduler.model_observatory import ModelObservatory
from uranography.api import ArmillarySphere, HorizonMap, MollweideMap, Planisphere

from schedview.collect import read_scheduler, sample_pickle
from schedview.plot.scheduler import (
DEFAULT_MJD,
DEFAULT_NSIDE,
LOGGER,
SchedulerDisplay,
)


class SchedulerDisplayApp(SchedulerDisplay):
Expand Down
2 changes: 1 addition & 1 deletion schedview/app/sched_maps/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
{{ plot_script|indent(8) }}
</body>

</html>
</html>
3 changes: 2 additions & 1 deletion schedview/app/start.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import bokeh.command.bootstrap
from pathlib import Path

import bokeh.command.bootstrap


def start_app(app_name):
"""Start a bokeh app.
Expand Down
2 changes: 1 addition & 1 deletion schedview/collect/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .metrics import get_metric_path # noqa F401
from .opsim import read_opsim # noqa F401
from .scheduler_pickle import read_scheduler # noqa F401
from .scheduler_pickle import sample_pickle # noqa F401
from .metrics import get_metric_path # noqa F401
from .stars import load_bright_stars # noqa F401
3 changes: 2 additions & 1 deletion schedview/collect/opsim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import sqlite3

import numpy as np
import pandas as pd
import sqlite3
from astropy.time import Time


Expand Down
13 changes: 7 additions & 6 deletions schedview/collect/scheduler_pickle.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import pickle
import os
import gzip
import bz2
import lzma
import gzip
import importlib.resources
from pathlib import Path
from tempfile import TemporaryDirectory
import lzma
import os
import pickle
import urllib
import urllib.request
from pathlib import Path
from tempfile import TemporaryDirectory

from rubin_sim.scheduler.model_observatory import ModelObservatory

__all__ = ["read_scheduler", "sample_pickle"]
Expand Down
3 changes: 2 additions & 1 deletion schedview/collect/stars.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections import OrderedDict
import os
from collections import OrderedDict

import pandas as pd

BSC5_URL = "http://tdc-www.harvard.edu/catalogs/bsc5.dat.gz"
Expand Down
10 changes: 3 additions & 7 deletions schedview/compute/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from .astro import convert_evening_date_to_night_of_survey, night_events
from .camera import LsstCameraFootprintPerimeter
from .scheduler import (
replay_visits,
compute_basis_function_reward_at_time,
compute_basis_function_rewards,
create_example,
make_unique_survey_name,
make_scheduler_summary_df,
make_unique_survey_name,
replay_visits,
)
from .survey import (
make_survey_reward_df,
compute_maps,
)

from .survey import compute_maps, make_survey_reward_df

__all__ = [
"convert_evening_date_to_night_of_survey",
Expand Down
7 changes: 4 additions & 3 deletions schedview/compute/astro.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from functools import cache
import datetime
from functools import cache

import numpy as np
import pandas as pd
from astropy.time import Time
import pytz
from rubin_sim.site_models.almanac import Almanac
from astropy.time import Time
from rubin_sim.scheduler.model_observatory import ModelObservatory
from rubin_sim.site_models.almanac import Almanac


@cache
Expand Down
2 changes: 1 addition & 1 deletion schedview/compute/camera.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import astropy.units as u
import numpy as np
import pandas as pd
from astropy.coordinates import SkyCoord
import astropy.units as u


class LsstCameraFootprintPerimeter(object):
Expand Down
7 changes: 4 additions & 3 deletions schedview/compute/maf_metrics.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from copy import deepcopy

from rubin_sim import maf
import schedview
import schedview.compute.astro
from rubin_sim.maf import MetricBundleGroup # noqa F401

# Imported to help sphinx make the link
from rubin_sim.scheduler.model_observatory import ModelObservatory # noqa F401
from rubin_sim.maf import MetricBundleGroup # noqa F401

import schedview
import schedview.compute.astro


def compute_night_metric_bundle(
Expand Down
18 changes: 9 additions & 9 deletions schedview/compute/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import copy
import datetime
import lzma
import numbers
import pickle

import numpy as np
import pandas as pd
import pickle
import lzma
import copy
import datetime
from astropy.timeseries import TimeSeries
from astropy.time import Time
from rubin_sim.scheduler.utils import empty_observation
from rubin_sim.scheduler.model_observatory import ModelObservatory
from rubin_sim.scheduler.example import example_scheduler
from astropy.timeseries import TimeSeries
from rubin_sim.scheduler import sim_runner
from rubin_sim.scheduler.utils import SchemaConverter
from rubin_sim.scheduler.example import example_scheduler
from rubin_sim.scheduler.model_observatory import ModelObservatory
from rubin_sim.scheduler.utils import SchemaConverter, empty_observation


def _make_observation_from_record(record):
Expand Down
7 changes: 4 additions & 3 deletions schedview/compute/survey.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from copy import deepcopy
from collections import OrderedDict
import numpy as np
from copy import deepcopy
from inspect import getmembers

import healpy as hp
import numpy as np
import rubin_sim.scheduler.basis_functions
from inspect import getmembers


def make_survey_reward_df(survey, conditions, reward_df=None):
Expand Down
2 changes: 1 addition & 1 deletion schedview/data/sample_prenight_custom_hvplots.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@
"height": 512
}
}
]
]
2 changes: 1 addition & 1 deletion schedview/data/test_prenight_custom_hvplots.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
"height": 512
}
}
]
]
2 changes: 1 addition & 1 deletion schedview/param.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Subclasses of param.Parameter for use in schedview.

import param
import pandas as pd
import param


class Series(param.Parameter):
Expand Down
18 changes: 9 additions & 9 deletions schedview/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
from .nightbf import plot_rewards, plot_infeasible
from .nightbf import plot_infeasible, plot_rewards
from .nightly import plot_airmass_vs_time, plot_alt_vs_time, plot_polar_alt_az
from .rewards import plot_survey_rewards, create_survey_reward_plot
from .rewards import create_survey_reward_plot, plot_survey_rewards
from .scheduler import (
make_logger,
BadSchedulerException,
BadConditionsException,
BadConditionsError,
BadSchedulerError,
SchedulerDisplay,
SchedulerNotebookDisplay,
make_logger,
)
from .survey import map_survey_healpix
from .visitmap import plot_visit_skymaps, plot_visit_planisphere, create_visit_skymaps
from .visits import plot_visits, create_visit_explorer
from .visitmap import create_visit_skymaps, plot_visit_planisphere, plot_visit_skymaps
from .visits import create_visit_explorer, plot_visits

__all__ = [
"plot_rewards",
Expand All @@ -21,8 +21,8 @@
"plot_survey_rewards",
"create_survey_reward_plot",
"make_logger",
"BadSchedulerException",
"BadConditionsException",
"BadSchedulerError",
"BadConditionsError",
"SchedulerDisplay",
"SchedulerNotebookDisplay",
"map_survey_healpix",
Expand Down
1 change: 0 additions & 1 deletion schedview/plot/nightbf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import bokeh
import numpy as np
from astropy.time import Time

from rubin_sim.scheduler.model_observatory import ModelObservatory


Expand Down
Loading

0 comments on commit ee2945f

Please sign in to comment.