-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
feat: Adding packagemeta to config and project manager #802
Conversation
|
code is not hitting my breakpoint within |
src/ape/managers/project/manager.py
Outdated
|
||
def publish_manifest(self): | ||
manifest = self.manifest.dict() | ||
if not manifest["name"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If name was not in the manifest, I believe self.manifest
would already raise a ValidationError
, no?
We should leave this method commented out, but at the same time, we could probably remove the if not
checks here since they happen at the model-level now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, name
and version
field are optional in spec, but recommended/required for publishing
https://github.com/ApeWorX/ethpm-types/blob/770ba756947215a58a41391c71cbe717708e8ab8/ethpm_types/manifest.py#L58-L60
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this resolved since this code has now been commented out for the time being?
src/ape/managers/project/manager.py
Outdated
|
||
def publish_manifest(self): | ||
manifest = self.manifest.dict() | ||
if not manifest["name"]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, name
and version
field are optional in spec, but recommended/required for publishing
https://github.com/ApeWorX/ethpm-types/blob/770ba756947215a58a41391c71cbe717708e8ab8/ethpm_types/manifest.py#L58-L60
# TODO: Publish sources to IPFS and replace with CIDs | ||
# TODO: Publish to IPFS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs #208 to complete these TODOs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required for this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we are building towards that though with the Deployments story
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#365 also this related issue for IPFS
# if not manifest["name"]: | ||
# raise ProjectError("Need name to release manifest") | ||
# if not manifest["version"]: | ||
# raise ProjectError("Need version to release manifest") | ||
# TODO: Clean up manifest and minify it | ||
# TODO: Publish sources to IPFS and replace with CIDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this would require looping through all the sources and publishing them to IPFS as well, then updating all of the links in the package from local links to global ones.
Also side-note is that eventually DependencyAPI
should store everything as IPFS content locally to make it super easy to publish
Co-authored-by: Juliya Smith <yingthi@live.com>
Co-authored-by: Juliya Smith <yingthi@live.com>
Co-authored-by: Juliya Smith <yingthi@live.com>
Co-authored-by: Juliya Smith <yingthi@live.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Update
config.md
to include information aboutmeta
It might be also worth adding a test in tests/functional/test_project.py
like test_manifest_config()
and use the temp_config()
fixture to temporary adjust the project config and make sure you can read it on the meta()
property you are adding as well other publishing related fields you are going to add over time, including name
and version
# def meta(self) -> PackageMeta: | ||
# return PackageMeta(**self.config_manager.get_config("ethpm").serialize()) | ||
@property | ||
def meta(self) -> PackageMeta: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- add doc str to this property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docstring added: e892b36 please review for completeness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added test, probably should be reworked: 230b1b5
# TODO: Publish sources to IPFS and replace with CIDs | ||
# TODO: Publish to IPFS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this required for this PR?
@unparalleled-js ipfs publishing is not required for this PR, this issue here is for IPFS publishing: #365 |
I can't seem to get this to actually function properly:
|
Although, more broadly speaking might need to fill in the meta fields for when dependencies get downloaded via |
need to add testing and make sure functionality works |
src/ape/managers/project/manager.py
Outdated
meta = self.config_manager.get_config("meta") | ||
try: | ||
return PackageMeta(**meta.serialize()) | ||
except Exception as e: | ||
raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code isn't getting ran when compiling or extracting manifest. I also have the following error in mypy src/ape/managers/project/manager.py:459: error: "PluginConfig" has no attribute "serialize"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does get ran when I do this command in console: In [1]: project.Token.project_manager.meta
src/ape/managers/config.py
Outdated
@@ -147,6 +152,7 @@ def _plugin_configs(self) -> Dict[str, PluginConfig]: | |||
user_config = load_config(config_file) if config_file.exists() else {} | |||
self.name = configs["name"] = user_config.pop("name", "") | |||
self.version = configs["version"] = user_config.pop("version", "") | |||
self.meta = configs["meta"] = user_config.pop("meta", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this look right?
src/ape/managers/project/manager.py
Outdated
meta = self.config_manager.get_config("meta") | ||
try: | ||
return PackageMeta(**meta.serialize()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try this:
meta = self.config_manager.get_config("meta") | |
try: | |
return PackageMeta(**meta.serialize()) | |
try: | |
return self.config_manager.meta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to get the meta into the project by using this
0b68bf1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still need to get the meta into the manifest
src/ape/managers/config.py
Outdated
@@ -147,6 +152,7 @@ def _plugin_configs(self) -> Dict[str, PluginConfig]: | |||
user_config = load_config(config_file) if config_file.exists() else {} | |||
self.name = configs["name"] = user_config.pop("name", "") | |||
self.version = configs["version"] = user_config.pop("version", "") | |||
self.meta = configs["meta"] = user_config.pop("meta", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with this
self.meta = configs["meta"] = user_config.pop("meta", "") | |
self.meta = configs["meta"] = PackageMeta(**user_config.pop("meta", "")) |
src/ape/managers/project/manager.py
Outdated
try: | ||
return self.config_manager.meta | ||
except Exception as e: | ||
raise ConfigError(f"Incorrect configuration of package metadata:\n{meta}") from e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flake8 . ./src/ape/managers/project/manager.py:459:80: F821 undefined name 'meta'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unparalleled-js I'm still having this issue and not sure how to resolve it.
src/ape/managers/project/manager.py
Outdated
# def meta(self) -> PackageMeta: | ||
# return PackageMeta(**self.config_manager.get_config("ethpm").serialize()) | ||
@property | ||
def meta(self) -> PackageMeta: # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably put the type ignore on the return stmt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this fixed the type issue.
src/ape/managers/project/manager.py
Outdated
@property | ||
def meta(self) -> PackageMeta: # type: ignore | ||
""" | ||
Populate package manifest with metadata as per EIP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not populate the manifest, so I would change this doc.
This just reads the value from the config manager.
Try something like
Metadata about the active project as per EIP ...
Use when publishing your package manifest.
tests/functional/test_project.py
Outdated
@@ -45,6 +46,12 @@ def test_extract_manifest(dependency_config, project_manager): | |||
assert type(manifest) == PackageManifest | |||
|
|||
|
|||
def test_meta(dependency_config, project_manager): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using dependency_config
, use the temp_config
fixture to make your own meta config:
def test_meta(temp_config, project_manager):
meta_config = {"meta": {"authors": ["Test Testerson"]}}
with temp_config(meta_config):
assert project_amager.meta.authors == ["Test Testerson"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expand on my example a little, add the other properties and stuff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What I did
Adding the package meta to the project config and project manager
fixes: #793
How I did it
following instructions laid out in issue #793
How to verify it
When it works, the package meta should be filled out in the contract manifest
Checklist