-
Notifications
You must be signed in to change notification settings - Fork 10
Add init command
#72
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
Merged
Merged
Add init command
#72
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
448b846
update links and add link to oceanparcels.org
VeckoTheGecko 33bba83
remove meta.yml
VeckoTheGecko b9efc63
Revert "disable linkcheck"
VeckoTheGecko 2fa14d8
Fix config and update readme
VeckoTheGecko bf5498e
Add PyYAML as explicit dependency
VeckoTheGecko 3a7507f
Add `virtualship.static` module and helpers
VeckoTheGecko 849c05b
Add validation of example configs
VeckoTheGecko 1fd1a20
Add virtualship init command
VeckoTheGecko b136162
Centralise file name assumptions
VeckoTheGecko 3ba4581
badges
VeckoTheGecko 926f63b
Specify package data in pyproject.toml
VeckoTheGecko f9da361
cleanup
VeckoTheGecko ae8c89c
Remove no-build-isolation flag in CI
VeckoTheGecko 4ec12fe
disable codecov comments
VeckoTheGecko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| See the following [contributing guide](../docs/contributing.md). | ||
| See the following [contributing guide](https://virtualship.oceanparcels.org/en/latest/contributing.html). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,3 +175,4 @@ cython_debug/ | |
| src/virtualship/_version_setup.py | ||
|
|
||
| .vscode/ | ||
| .DS_Store | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| coverage: | ||
| status: | ||
| project: | ||
| default: | ||
| informational: true | ||
| patch: | ||
| default: | ||
| informational: true | ||
| comment: false | ||
| # When modifying this file, please validate using | ||
| # curl -X POST --data-binary @codecov.yml https://codecov.io/validate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ dependencies: | |
| - numpy >=1, < 2 | ||
| - pydantic >=2, <3 | ||
| - pip | ||
| - pyyaml | ||
|
|
||
| # linting | ||
| - pre-commit | ||
|
|
||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| """Module to put static assets. Should not be used for data.""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| waypoints: | ||
| - instrument: CTD | ||
| location: | ||
| latitude: 0 | ||
| longitude: 0 | ||
| time: 2023-01-01 00:00:00 | ||
| - instrument: DRIFTER | ||
| location: | ||
| latitude: 0.01 | ||
| longitude: 0.01 | ||
| time: 2023-01-01 01:00:00 | ||
| - instrument: ARGO_FLOAT | ||
| location: | ||
| latitude: 0.02 | ||
| longitude: 0.02 | ||
| time: 2023-01-01 02:00:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| ship_speed_meter_per_second: 5.14 | ||
| adcp_config: | ||
| num_bins: 40 | ||
| max_depth_meter: -1000.0 | ||
| period_minutes: 5.0 | ||
| argo_float_config: | ||
| cycle_days: 10.0 | ||
| drift_days: 9.0 | ||
| drift_depth_meter: -1000.0 | ||
| max_depth_meter: -2000.0 | ||
| min_depth_meter: 0.0 | ||
| vertical_speed_meter_per_second: -0.1 | ||
| ctd_config: | ||
| max_depth_meter: -2000.0 | ||
| min_depth_meter: -11.0 | ||
| stationkeeping_time_minutes: 20.0 | ||
| drifter_config: | ||
| depth_meter: 0.0 | ||
| lifetime_minutes: 40320.0 | ||
| ship_underwater_st_config: | ||
| period_minutes: 5.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| from functools import lru_cache | ||
| from importlib.resources import files | ||
|
|
||
| SCHEDULE = "schedule.yaml" | ||
| SHIP_CONFIG = "ship_config.yaml" | ||
| CHECKPOINT = "checkpoint.yaml" | ||
|
|
||
|
|
||
| def load_static_file(name: str) -> str: | ||
| """Load static file from the ``virtualship.static`` module by file name.""" | ||
| return files("virtualship.static").joinpath(name).read_text(encoding="utf-8") | ||
|
|
||
|
|
||
| @lru_cache(None) | ||
| def get_example_config() -> str: | ||
| """Get the example configuration file.""" | ||
| return load_static_file(SHIP_CONFIG) | ||
|
|
||
|
|
||
| @lru_cache(None) | ||
| def get_example_schedule() -> str: | ||
| """Get the example schedule file.""" | ||
| return load_static_file(SCHEDULE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| from pathlib import Path | ||
|
|
||
| import pytest | ||
| from click.testing import CliRunner | ||
|
|
||
| from virtualship.cli.commands import init | ||
| from virtualship.utils import SCHEDULE, SHIP_CONFIG | ||
|
|
||
|
|
||
| def test_init(): | ||
| runner = CliRunner() | ||
| with runner.isolated_filesystem(): | ||
| result = runner.invoke(init, ["."]) | ||
| assert result.exit_code == 0 | ||
| config = Path(SHIP_CONFIG) | ||
| schedule = Path(SCHEDULE) | ||
|
|
||
| assert config.exists() | ||
| assert schedule.exists() | ||
|
|
||
|
|
||
| def test_init_existing_config(): | ||
| runner = CliRunner() | ||
| with runner.isolated_filesystem(): | ||
| config = Path(SHIP_CONFIG) | ||
| config.write_text("test") | ||
|
|
||
| with pytest.raises(FileExistsError): | ||
| result = runner.invoke(init, ["."]) | ||
| raise result.exception | ||
|
|
||
|
|
||
| def test_init_existing_schedule(): | ||
| runner = CliRunner() | ||
| with runner.isolated_filesystem(): | ||
| schedule = Path(SCHEDULE) | ||
| schedule.write_text("test") | ||
|
|
||
| with pytest.raises(FileExistsError): | ||
| result = runner.invoke(init, ["."]) | ||
| raise result.exception |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from virtualship.expedition import Schedule, ShipConfig | ||
| from virtualship.utils import get_example_config, get_example_schedule | ||
|
|
||
|
|
||
| def test_get_example_config(): | ||
| assert len(get_example_config()) > 0 | ||
|
|
||
|
|
||
| def test_get_example_schedule(): | ||
| assert len(get_example_schedule()) > 0 | ||
|
|
||
|
|
||
| def test_valid_example_config(tmp_path): | ||
| path = tmp_path / "test.yaml" | ||
| with open(path, "w") as file: | ||
| file.write(get_example_config()) | ||
|
|
||
| ShipConfig.from_yaml(path) | ||
|
|
||
|
|
||
| def test_valid_example_schedule(tmp_path): | ||
| path = tmp_path / "test.yaml" | ||
| with open(path, "w") as file: | ||
| file.write(get_example_schedule()) | ||
|
|
||
| Schedule.from_yaml(path) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.