Open jamiezieziula opened 1 year ago
@zanieb @jamiezieziula Can I work on this?
@anudeepadi Sure, that would be great! I've assigned the issue to you. Let us know if you have questions, and we look forward to reviewing your pull request.
I think it would also be useful to integrate yamllint into our test suite (so that we can detect any issues as our generator changes; it looks like that should be possible as yamllint offers a Python API), but that's not necessary for this issue.
Hey @jawnsy, I have implemented the changes as suggested in the issue the YAML files have proper indentation, and I've limited the line lengths to 80 characters to avoid any issues with CI pipelines. I've tested the script on a sample YAML file, and the updated output is looking good. Could you please review the code below? Additionally, I've noticed that integrating yamllint into our test suite might be beneficial for detecting issues as the generator changes. However, I understand it might not be necessary for this specific issue. I'd be happy to work on this integration separately in the future. Here's the Python script I've used for this task:
import yaml
import textwrap
def check_indentation(data, indent=0):
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, (dict, list)):
check_indentation(value, indent + 2)
elif isinstance(data, list):
for item in data:
check_indentation(item, indent + 2)
def limit_line_length(data, max_line_length=80):
if isinstance(data, dict):
for key, value in data.items():
if isinstance(value, (dict, list)):
limit_line_length(value, max_line_length)
elif isinstance(data, list):
for idx, item in enumerate(data):
if isinstance(item, str) and len(item) > max_line_length:
data[idx] = "\n".join(textwrap.wrap(item, width=max_line_length))
if __name__ == "__main__":
input_file = "sample.yaml"
output_file = "sample_updated.yaml"
# Step 1: Read YAML file
with open(input_file, "r") as f:
yaml_data = yaml.safe_load(f)
# Step 2: Check indentation
check_indentation(yaml_data)
# Step 3: Limit line length
limit_line_length(yaml_data)
# Step 4: Write updated YAML file
with open(output_file, "w") as f:
yaml.dump(yaml_data, f, indent=2)
print("YAML file processed and updated.")
First check
Prefect Version
2.x
Describe the current behavior
Currently
prefect project init
generates two yaml files (deployment.yaml & prefect.yaml). These files "as is" will be flagged in any generic yaml linter (like yamllint):Describe the proposed behavior
Any generated yaml files should confirm with common yaml standards to avoid being flagged by end-users ci pipelines. Specifically, there should be indents on lists and lines should not exceed 80 chars:
Example Use
No response
Additional context
No response