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

Rename LocalStorage -> Local #1236

Merged
merged 2 commits into from
Jul 15, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ These changes are available in the [master branch](https://github.com/PrefectHQ/
- The `slack_notifier` state handler now uses a `webhook_secret` kwarg to pull the URL from a Secret - [#1075](https://github.com/PrefectHQ/prefect/issues/1075)
- Use GraphQL for Cloud logging - [#1193](https://github.com/PrefectHQ/prefect/pull/1193)
- Remove the `CloudResultHandler` default result handler - [#1198](https://github.com/PrefectHQ/prefect/pull/1198)
- Rename `LocalStorage` to `Local` - [#1236](https://github.com/PrefectHQ/prefect/pull/1236)

### Contributors

Expand Down
2 changes: 1 addition & 1 deletion docs/outline.toml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ classes = ["CloudFlowRunner", "CloudTaskRunner"]
[pages.environments.storage]
title = "Storage"
module = "prefect.environments.storage"
classes = ["Storage", "Docker", "LocalStorage", "Memory", "Bytes"]
classes = ["Storage", "Docker", "Local", "Memory", "Bytes"]

[pages.environments.execution]
title = "Execution Environments"
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/environments/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
from prefect.environments.storage.base import Storage
from prefect.environments.storage.docker import Docker
from prefect.environments.storage.bytes import Bytes
from prefect.environments.storage.local import LocalStorage
from prefect.environments.storage.local import Local
from prefect.environments.storage.memory import Memory
4 changes: 2 additions & 2 deletions src/prefect/environments/storage/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
from prefect.core.flow import Flow


class LocalStorage(Storage):
class Local(Storage):
"""
Local Storage class. This class represents the Storage
Local storage class. This class represents the Storage
interface for Flows stored as bytes in the local filesystem.

Args:
Expand Down
6 changes: 3 additions & 3 deletions src/prefect/serialization/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from marshmallow import fields, post_load

import prefect
from prefect.environments.storage import Bytes, Docker, LocalStorage, Memory, Storage
from prefect.environments.storage import Bytes, Docker, Local, Memory, Storage
from prefect.utilities.serialization import Bytes as BytesField
from prefect.utilities.serialization import ObjectSchema, OneOfSchema

Expand All @@ -30,7 +30,7 @@ def create_object(self, data: dict, **kwargs: Any) -> Docker:

class LocalSchema(ObjectSchema):
class Meta:
object_class = LocalStorage
object_class = Local

directory = fields.Str(allow_none=False)
flows = fields.Dict(key=fields.Str(), values=fields.Str())
Expand Down Expand Up @@ -76,6 +76,6 @@ class StorageSchema(OneOfSchema):
"Bytes": BytesSchema,
"Docker": DockerSchema,
"Memory": MemorySchema,
"LocalStorage": LocalSchema,
"Local": LocalSchema,
"Storage": BaseStorageSchema,
}
24 changes: 12 additions & 12 deletions tests/environments/storage/test_local_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@

import prefect
from prefect import Flow
from prefect.environments.storage import LocalStorage
from prefect.environments.storage import Local
from prefect.utilities.configuration import set_temporary_config


def test_create_local_storage():
storage = LocalStorage()
storage = Local()
assert storage
assert storage.directory.endswith(".prefect/flows")


def test_create_local_storage_with_custom_dir():
storage = LocalStorage(directory=".")
storage = Local(directory=".")
assert storage
assert os.path.isabs(storage.directory)


def test_add_flow_to_storage():
with tempfile.TemporaryDirectory() as tmpdir:
storage = LocalStorage(directory=tmpdir)
storage = Local(directory=tmpdir)
f = Flow("test")
assert f.name not in storage

Expand All @@ -41,7 +41,7 @@ def test_add_flow_to_storage():

def test_add_flow_raises_if_name_conflict():
with tempfile.TemporaryDirectory() as tmpdir:
storage = LocalStorage(directory=tmpdir)
storage = Local(directory=tmpdir)
f = Flow("test")
res = storage.add_flow(f)
g = Flow("test")
Expand All @@ -51,20 +51,20 @@ def test_add_flow_raises_if_name_conflict():


def test_get_env_runner_raises():
s = LocalStorage()
s = Local()
with pytest.raises(NotImplementedError):
s.get_env_runner("")


def test_get_flow_raises_if_flow_not_present():
s = LocalStorage()
s = Local()
with pytest.raises(ValueError):
s.get_flow("test")


def test_get_flow_returns_flow():
with tempfile.TemporaryDirectory() as tmpdir:
storage = LocalStorage(directory=tmpdir)
storage = Local(directory=tmpdir)
f = Flow("test")
loc = storage.add_flow(f)
runner = storage.get_flow(loc)
Expand All @@ -73,7 +73,7 @@ def test_get_flow_returns_flow():

def test_containment():
with tempfile.TemporaryDirectory() as tmpdir:
s = LocalStorage(directory=tmpdir)
s = Local(directory=tmpdir)
f = Flow("test")
s.add_flow(f)

Expand All @@ -86,7 +86,7 @@ def test_containment():

def test_build_returns_self():
with tempfile.TemporaryDirectory() as tmpdir:
s = LocalStorage(directory=tmpdir)
s = Local(directory=tmpdir)
assert s.build() is s

f = Flow("test")
Expand All @@ -96,7 +96,7 @@ def test_build_returns_self():

def test_multiple_flows_in_storage():
with tempfile.TemporaryDirectory() as tmpdir:
s = LocalStorage(directory=tmpdir)
s = Local(directory=tmpdir)
f = Flow("test")
g = Flow("other")
z = Flow("not")
Expand All @@ -116,7 +116,7 @@ def test_multiple_flows_in_storage():

def test_add_flow_with_weird_name_is_cleaned():
with tempfile.TemporaryDirectory() as tmpdir:
s = LocalStorage(directory=tmpdir)
s = Local(directory=tmpdir)
flow = Flow("WELL what do you know?!~? looks like a test!!!!")
loc = s.add_flow(flow)
assert "?" not in loc
Expand Down
4 changes: 2 additions & 2 deletions tests/serialization/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_bytes_roundtrip():


def test_local_empty_serialize():
b = storage.LocalStorage()
b = storage.Local()
serialized = LocalSchema().dump(b)

assert serialized
Expand All @@ -113,7 +113,7 @@ def test_local_empty_serialize():

def test_local_roundtrip():
with tempfile.TemporaryDirectory() as tmpdir:
s = storage.LocalStorage(directory=tmpdir)
s = storage.Local(directory=tmpdir)
flow_loc = s.add_flow(prefect.Flow("test"))
serialized = LocalSchema().dump(s)
deserialized = LocalSchema().load(serialized)
Expand Down